Hello,
I am trying to create a new message in my application and when I click
on the submit button to create the new message, I get redirected to the
form to create a new message. Here is my code:
class MessageController < ApplicationController
before_filter :logged_in?
def new
@message = Message.new
end
def create
@message = Message.new(params[:message])
if @message.save
flash[:notice] = ''Message sent successfully!''
redirect_to :controller => ''client'', :action =>
''show'', :id =>
session[:client]
else
render :text => ''Something invalid!''
end
end
end
Here is my .rhtml file:
<html>
<head>
<title>New Message</title>
</head>
<body>
<form method="POST" action="create/<%= @message.id
%>">
<input type="hidden" id="message_id"
name="message[id]" value="<%@message.id %>" />
<input type="hidden" id="message_inbox_id"
name="message[inbox_id]"
value="<%= params[:inbox_id] %>" />
<input type="hidden" id="message_sender_id"
name="message[sender_id]" value="<%= params[:id] %>"
/>
<p><b>Subject: </b><input type="text"
id="message_title"
name="message[title]" value="<%= @message.title %>"
/></p>
<p><b>Message: </b><textarea
id="message_body"
name="message[body]"></textarea></p>
<p><input type="submit" id="messageCreate"
value="Send" /></p>
</form>
</body>
</html>
Thanks
M.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---