On 21 April 2012 08:39, amvis <[email protected]> wrote: > I have changed the code like this > class BranchesController < ApplicationController > def branch > @branch = Branch.new > end > > def create > @branch = Branch.new(params[:branch]) > end > end > branch.html.erb in branches folder > > <%= form_for(@branch) do |f| %> > <%end%> > > > Now the problem is if i want to display some value from branches controller > to branch.html.erb, i have to define that in branch method > in BranchesController, but here all the functionality can be done in create > method in BranchesController, so that way i didn't get any values in > branch.html.erb, How to do that....?. How to write that in branch method?.. > if the branch method not in BranchesController, the error will be undefined > method model_name nill class, also if the create method not > in BranchesController, the error will be the action create not found > > What am i doing wrong
I don't have much idea about what problem you are trying to describe, I presume English is not your first language and understand it can be difficult to explain a problem clearly. If I am right then you have an action branch in the branches controller but have the problem that in order for data to be seen in the view then you have to setup variables in that action. If you don't want to set them up there then possibly a before_filter is what you want. If I am not understanding the problem correctly then please try again to explain it. Cut your example down to the absolute minimum code required and show what you are trying to do and what the problem is. After writing your description of the problem imagine yourself as someone who knows nothing about your requirement, read your description carefully, and make sure the description of the problem is clear. Colin > thanks.. > > > > On Saturday, 21 April 2012 01:21:51 UTC-4, amvis wrote: >> >> class BranchesController < ApplicationController >> def branch >> @branch = Branch.new (params[:branch]) >> branch_back = @branch.branch >> end >> end >> >> in the model have one branch.rb >> class Branch >> def branch >> end >> end >> >> In the view have one branches folder, also have the branch.html.erb in >> that folder. >> <%= form_for(@branch) do |f| %> >> <%end%> >> >> routes.rb >> >> match 'branch' => 'branches#branch' >> resources :branches >> >> i am getting this following error >> >> NoMethodError in BranchesController#branch >> >> You have a nil object when you didn't expect it! >> You might have expected an instance of Array. >> The error occurred while evaluating nil.each >> >> What am I doing wrong? >> Thank you >> >> vishnu >> >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/765tgLwVuLwJ. > > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

