Leonel *.* wrote in post #1016258:
> Is it maybe because it's a nested resource?
>

Possibly.   This certainly works:

class PagesController < ApplicationController
  def home
    @title = "Home"
  end

end

===


Test2App::Application.routes.draw do
  resources :users
  root :to => "pages#home"


===


class UsersController < ApplicationController
  def new
    @user = User.new
    @title = "Sign up"
  end

  def create
    @user = User.new(params[:user])
    @user.last_sent_to = @user.email

    if @user.save
      @title = "Home"
      render 'pages/home'
    else
      @title = "Sign up"
      render 'new'
    end
  end


  def show
  end

end


===


<h1>Pages#home</h1>
<p>Find me in app/views/pages/home.html.erb</p>

<%= link_to "New user form", new_user_path %>


===


<h1>Users#new</h1>
<p>Find me in app/views/users/new.html.erb</p>

<%= form_for(@user) do |f| %>

  <div><%= f.label :email %></div>
  <div><%= f.text_field :email %></div>

  <div><%= f.submit "Submit" %></div>

<% end %>


===


<!DOCTYPE html>
<html>
<head>
  <title><%= @title %></title>
  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>
</head>
<body>

<%= yield %>

</body>
</html>

===


<h1>Users#new</h1>
<p>Find me in app/views/users/new.html.erb</p>

<%= form_for(@user) do |f| %>

  <div><%= f.label :email %></div>
  <div><%= f.text_field :email %></div>

  <div><%= f.submit "Submit" %></div>

<% end %>


===

http://localhost:3000  => home page

click link on home page => new.html.erb

fill in form and click submit => data for both :email and :last_sent_to 
appears in database for data

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to