I have the controller action:
class UsersController < ApplicationController
def new
@user = User.new
if params[:email]
@email = params[:email]
@user.email = @email
end
end
def create
@user = User.new(user_params)
@user.save
redirect_to root_path
end
private
def user_params
params.require(:user).permit(:name, :email)
end
end
and this is the form in my footer (which is working since its passing the params) -> the button-div is bootstrap:
<%= form_tag new_user_path, class: "email-control", method: :get do %>
<%= text_field_tag :email,
params[:email],
class: "email-bar",
placeholder: "Type your email..."
%>
<div class="input-group-append">
<button type="submit" class="button-sent" data-bs-toggle="modal" data-bs-target="#login-popup"><i class="far fa-paper-plane"></i></i></button>
</div>
<% end %>
BUT the following simple_form should be a MODAL appearing on every page I type in my email in the footer:
<div class="login-container">
<div class="row center-div">
<div class="col-xs-12 col-sm-4 col-sm-offset-4">
<div class="form-login">
<h2>Send me Newsletters</h2>
<%= simple_form_for(@user) do |f| %>
<div class="form-inputs">
<%= f.input :name, required: false, autofocus: true %>
<%= f.input :email, required: false %>
</div>
<div class="form-actions">
<%= f.button :submit, "⤏Submit⤎", class: "email-control " %>
</div>
<% end %>
</div>
</div>
</div>
</div>
When following this page:
https://kolosek.com/rails-creating-modals/
I was able to see this: I guess the JS is not working?
I also think the issues is that my controller action can only be red by the new.html.erb view and can therefore not be reached by any other page?
Thank you so much for helping.