Note that there are some explanatory texts on larger screens.

plurals
  1. PORails Form Object show action
    text
    copied!<p>I am trying to figure out how to write the show action for Form Objects.</p> <p>The following is code taken from RailsCast episode 416 <a href="https://github.com/railscasts/416-form-objects/tree/master/signup-after" rel="nofollow">project</a></p> <p><strong>app/forms/signup_form.rb</strong></p> <pre><code>class SignupForm # Rails 4: include ActiveModel::Model extend ActiveModel::Naming include ActiveModel::Conversion include ActiveModel::Validations def persisted? false end def self.model_name ActiveModel::Name.new(self, nil, "User") end validates_presence_of :username validate :verify_unique_username validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/ validates_length_of :password, minimum: 6 delegate :username, :email, :password, :password_confirmation, to: :user delegate :twitter_name, :github_name, :bio, to: :profile def user @user ||= User.new end def profile @profile ||= user.build_profile end #... end </code></pre> <p><strong>app/controllers/users_controller.rb</strong></p> <pre><code>class UsersController &lt; ApplicationController def new @signup_form = SignupForm.new end def create @signup_form = SignupForm.new if @signup_form.submit(params[:user]) session[:user_id] = @signup_form.user.id redirect_to @signup_form.user, notice: "Thank you for signing up!" else render "new" end end def show @user = current_user end end </code></pre> <p>I don't see how one would pass in the ID of the model and specify the variables.</p> <p>Does anyone have an example or can provide one using the episode's code as a starting point?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload