Forum: Ruby on Rails learning how models, controllers, and views pass data

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jason P. (Guest)
on 2006-01-23 03:16
As a noob to Rails and web development in general, I think I still need
a broader understanding of how Views, Controllers, and Models pass
information and variables to each other.

I'm creating a site that allows for email campaigns.  I have a

class Admin::CreateEmailController < Admin::BaseController
	layout 'admin'
  def index
    render :action => 'write'

  def write
    @email =

  def email_list
 	 email = Email.find(:all)
 	 email.each { |address| MailList::deliver_send_email(address) }
 	 redirect_to (:action => @section)


where I want the user to type a message body into a textarea field:

<%= error_messages_for 'email' %>

<p><label for="email_message">Message</label><br/>
<%= text_area 'email', 'message'  %></p>


I want to pass from the form a variable @message to email_list in the
controller, which passes to the MailList model:

class MailList < ActionMailer::Base
	def send_email(email)
		@recipients = email.address
		@from = 'removed_email_address@domain.invalid'
		@subject = 'Toro Paintball'
		@body['full_name'] = email.fullname
                ## @message in here someway ##

which invokes the view send_email.rhtml:

Dear <%= @full_name %>,

<%= @message %>

Hope this isn't way too long winded, but is this completely simple to do
without having to store @message as a session variable or in the DB?
Can I just take the value of the textarea, pass it through the
controllers and model to the view like this?
Guest (Guest)
on 2006-01-23 14:31
In your controller, you can get the message variable with something like
this :


More generally, params holds all your form's variables
This topic is locked and can not be replied to.