I began learning rails several days before. Here I have a project setup. I generate a new controller named "my", the method in it is called "update". The controller is like:
class MyController < ApplicationController
def update
@person = Entry.last
@fname = @person.first_name
@lname = @person.last_name
@person.update_attributes({:address => params[:st_name],
:salary => params[:salary], :loan => params[:loan],
:loan_reason => params[:reason]})
if !@person.address.nil? then render "show" end
end
end
In my form of the HTML, codes are:
<%= form_tag**({:controller => "my", :action => "update"} , :method => 'get')** do %>
<p> Address: <%= text_field_tag 'st_name', @address %>
<p> Salary:
<%= text_field_tag 'salary', @salary %>
<p> Loan Amount:
<%= text_field_tag 'loan', @loan %>
<p> Loan Reason:
<%= text_field_tag 'reason', @loan_reason %>
<%= submit_tag 'send' %>
<% end %>
Must have something wrong with the 1 line.
When I run the project, it says: Unknown action The action 'update' could not be found for OtherController
Can anyone give me some advece? Thanks...
应该是:url => {:controller => "my", :action => "update"}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.