This is a noob question!
How can I save the model Action, once when I try to save in the controller, the params[:action] is taken by the action controller..
Here is my controller:
def viewTask()
@id = params[:id]
@task = Task.find(@id)
@status = Status.find(@task.status_id)
@actions = Action.where("task_id = #{@id}")
@action = Action.new
if params[:action]
@action = Action.new(:message => params[:action], :task_id => @id)
@action.save
end
end
Here’s my view:
<%= form_for :action do |a| %>
<%= a.text_area :message, :cols => 10, :rows => 5 %>
<%= a.submit 'ok', :class=> "btn" %>
<% end %>
Thanks Everyone.
This answer is more like a comment, but it is so hard to understand, what the question is about, so I decided to have this as an answer.
Come on, Fernando, how can we know what you’re trying to do? What action should the form be submitted to? Can you show us your routes.rb, so we know, how the action form can submit to your controller action. Maybe, to avoid problems with naming conventions in rails, you should rename your
ActionModel and Controller to something likeMissionorActivity.What should your
paramsHash look like? Because there will always be a params[:action], that in case of a form normally iscreateorupdate.Further, please try to use the built in rails methods, like:
In the code, I am assuming, that you’re task model looks something like this: