Yep, this was the problem. The Rails app initialized before the database
initialized, hence the database was not available at the moment the class
was created. Easy fix.
Thanks!
Andrew
On Monday, November 18, 2013 3:13:11 PM UTC-5, Jeremy Evans wrote:
>
> On Monday, November 18, 2013 11:59:04 AM UTC-8, Andrew Burleson wrote:
>>
>> Cross posting this from IRC, not sure which one is more likely to get a
>> quick response... Thanks for any help!
>>
>> I'm using Sequel in a simple Rails app, and I'm getting NoMethodError for
>> attribute methods. IE. for my user model, there is a column in the database
>> like first_name or last_name, but when I call user.first_name I get
>> NoMethodError, even when the @values hash that shows up in the console
>> includes those attributes
>>
>> So for example: if I put `user` in console I get
>>
>> #<User @values={:id=>1, :first_name=>"Admin", :last_name=>"Tester",
>> :email=>"[email protected]", :role=>"admin", :created_at=>2013-10-01
>> 23:28:09 -0400, :updated_at=>2013-10-18 22:43:51 -0400}
>>
>> but if I call `user.first_name` I get
>>
>> #<NoMethodError: undefined method `first_name' for
>> #<User:0x007fb38676e198>>
>>
>> It looks like the @values stuff is not getting accessor methods
>> instantiated, but I don't see why that would be. Has anyone run into this
>> kind of issue before
>>
>
> Sequel should be creating accessors for all of the columns in the model's
> dataset. Are you sure those columns are in the table at the time you are
> creating the model class? If not, that's the problem, and you shouldn't
> delay creating the model class until after the database table has already
> been setup. If so, there is some other issue, so please post a
> self-contained example showing the problem.
>
> Thanks,
> Jeremy
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.