ruby on rails: Binding a view to a non database model -


i have bound particular view non database model .

here model

class shelfdetailstep    attr_accessor :leftmostbinid, :numberofbins       end 

here view takes object controller

<%=  form_for @shelfdetailobject,  :as => :shelfdetailstep, :url => { :action  =>  "validate_random_bin" }  |f| %>                    <div>enter number of bins in shelf  </div>             <%= f.text_field :numberofbins %>             <%= submit_tag  'enter' %>         <%  end  %> 

the object shelfdetailobject created controller.here adding <%= form_for @shelfdetailobject..%> threw undefined model_name error. had add <% form_for @shelfdetailobject, :as => :shelfdetailstep...%> working.

why did have when code samples typically use objectname bind view model? not work when tried name object @shelfdetailstep.

you can use active model's power. add module want class.

add following lines inside shelfdetailstep class

include activemodel::validations include activemodel::conversion extend activemodel::naming 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -