I have problem with creating a form for my ActiveResource models but I can't seem to find a solution. The problem is that the model does not know the fields, and throws an error when I try to create a text field:
undefined method `firstname' for #<User:0x00000002946ec8>
For this form:
<%= form_for(@user) do |f| %>
<div class="field">
<%= f.label :firstname %><br>
<%= f.text_field :firstname %>
</div>
This is my from my controller:
def new
@user = User.new
end
Thie is my user model:
class User < ActiveResource::Base
self.site = "https://***.com/api/v1.0/"
end
I tried the following, but that does not work well with ActiveResource models, it is somehow not able to store retrieved data anymore. user.firstname is empty, when i remove the line it is not...
attr_accessor :firstname, :lastname
Then I found the gem Fortify (https://rubygems.org/gems/fortify) but the last update was in 2010 and installing it doesn't work...
I hope someone is familiar with this problem and can help me in the right direction.
rails console
typeUser
and show the output? I suspect that you might forgot to createfirsname
field when you were generating User model. – Elapse