On Saturday, 21 April 2012 04:19:05 UTC-4, Colin Law wrote:
>
> On 21 April 2012 09:14, amvis <[email protected]> wrote: 
> > ... 
> >    what i am trying to do, 
> > 
> > branches_controller 
> > 
> > class BranchesController < ApplicationController 
> >    def branch 
> >      @branch = Branch.new 
> >    end 
> > 
> >    def create 
> >      @branch = Branch.new(params[:branch]) 
> >      @name = "vishnu" 
> >    end 
> >  end 
> > 
> > branch.html.erb 
> > <h4> new  <%=@name %> </h4> 
> >  <%= form_for(@branch) do |f| %> 
> >    <%= f.submit "Save" %> 
> >   <%end%> 
> > 
> >  if i have to get @name in branch.html.erb, i have to define that branch 
> > action in BranchesController, am i correct...?. So in this application 
> all 
> > the main function done in create action in BranchesController. In that 
> way 
> > how to get that values in branch.html.erb 
>
>     Thanks
   Can i do like that,

    class BranchesController < ApplicationController  
     before_filter :branch,:create
    def branch 
      @branch = Branch.new 
    end 
 
    def create 
      @branch = Branch.new(params[:branch]) 
      @name = "vishnu" 
    end 
  end 
  
Is it correct way...? 

 

> Use before_filter to setup @name for both create and branch. 
>
> Colin 
>

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