title: Calling Methods in Rails - From Controller or from Views
body: <p>I have a problem with calling methods.  Here is the code from one of my Controllers:</p>
  
  <pre><code>class MethodsController &lt; ApplicationController
    def details
      @title = "User Details"
      @fname = params[:first_name]
      @lname = params[:last_name]
      @exam_no = params[:exam_no]
      if @fname &amp;&amp; @lname then
        @candidate = Candidate.create({:first_name =&gt; @fname, :last_name =&gt; @lname,:exam_number =&gt; @exam_no})         
        grades   #This method call doesn't work
      end
  
    end
  
    def grades
      @title = "Enter Grades"
      @candidate = Candidate.find(:last)
      @grades = params[:grades]
      @candidate.update_attributes({:grades =&gt; params[:grades]})
    end
  end
  </code></pre>
  
  <p>The details method works fine, clicking the 'submit' button on the 'details' view creates the Candidate and I can 'link_to' the next page.</p>
  
  <p>What I really want to do is: Click 'submit' and be automatically taken to the next view, 'grades' (which is also shown above).  I thought a method call to 'grades' in 'details would work, but it doesn't.  The 'grades' page title appears, but the view for 'details' still remains.</p>
  
  <p>Is there some way to do this?  Possibly call the 'grades' method from 'details' view?  I know that's not best practice, but I'm stuck.  (I tried @controller.grades but I get a NoMethodError - @controller is nil).  I also tried render 'grades' but of course while it renders the view, it doesn't execute the code.</p>