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
 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.

Reply via email to