Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the mass_assignment: false example in the README out of date? #325

Closed
lnikkila opened this issue Jun 14, 2015 · 2 comments
Closed

Is the mass_assignment: false example in the README out of date? #325

lnikkila opened this issue Jun 14, 2015 · 2 comments
Labels

Comments

@lnikkila
Copy link

Here’s the relevant part:

# include attribute DSL + constructor
class User
  include Virtus.model(:mass_assignment => false)

  attribute :name, String
end

User.new(:name => 'Piotr')

I’m running 1.0.5 and for me this results in a NoMethodError:

NoMethodError: undefined method `allowed_writer_methods' for User:Class
from /Users/lnikkila/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/virtus-1.0.5/lib/virtus/class_inclusions.rb:32:in `allowed_writer_methods'

User.new works fine. Is the other initializer still supported?

I’d really like to use it since I want an attribute called attributes (#206) and I don’t really care about mass assignment otherwise.

Looks like the error was introduced by a385ca2. If I do

User.extend(Virtus::Extensions::AllowedWriterMethods)

it works as expected, except for setting the attributes attribute in the initializer. Currently I’m using it as a workaround.

Thanks!

@solnic
Copy link
Owner

solnic commented Jun 16, 2015

Thanks for reporting this. Looks like a bug :/

@solnic solnic added the bug label Jun 16, 2015
@novikserg
Copy link
Contributor

@solnic I would like to solve it if you didn't get started on it yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants