Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Devise is an <em>authentication</em> library. If you are looking to have users sign up to access different parts of your app (requiring authentication), then you could use devise.</p> <p>If you just want to gather data from people visiting your app, you can just create a simple resource.</p> <pre><code># generate model bundle exec rails g model UserSignup email # run migration bundle exec rake db:migrate </code></pre> <p>Then configure your routes.</p> <pre><code># config/routes.rb resources :user_signups, only: [:new, :create] root 'user_signups#new' </code></pre> <p>Then your controller:</p> <pre><code># app/controllers/user_signups_controller.rb class UserSignupsController &lt; ApplicationController def new @user_signup = UserSignup.new end def create @user_signup = UserSignup.new(user_signup_params) if @user_signup.save redirect_to root_url, notice: "Thank you for expressing interest." else render action: 'new', alert: "Signup failed." end end private def user_signup_params params.require(:user_signup).permit(:email) end end </code></pre> <p>And finally your view:</p> <pre><code># app/views/user_signups/new.html.erb &lt;h1&gt;Signup to Express Your Interest!&lt;/h1&gt; &lt;%= form_for @user_signup do |f| %&gt; &lt;% if @user_signup.errors.any? %&gt; &lt;div id="error_explanation"&gt; &lt;h2&gt;&lt;%= pluralize(@user_signup.errors.count, "error") %&gt; prohibited your registration from being completed:&lt;/h2&gt; &lt;ul&gt; &lt;% @user_signup.errors.full_messages.each do |msg| %&gt; &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;/div&gt; &lt;% end %&gt; &lt;div class="field"&gt; &lt;%= f.label :email %&gt;&lt;br&gt; &lt;%= f.text_field :email %&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>That should get you started and you can start fleshing out the pages, email validations, etc. Also, you may want to redirect to somewhere other than the <code>root_url</code> from the create action, but you can probably figure out how to do that.</p> <p>So that will get the data in the database, but if you want to view the collected data through the app (rather that directly in the database), that's when you'd use something like devise to lock down the places in your app that display the user data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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