I have a function that redirects to a countdown while our system is offline, however I’d still like registration to be available from the countdown page (as opposed to the registration page).
Can I change the current registrations view (if so, how?) to still use the registrations_controller, or will I have to add redundant code to my application_controller to make this work?
I’m a rails newbie, so speak slowly, please. 🙂
In summation, I have a working system, but don’t know how to make the registration form work from outside it’s current location. (Because I followed tutorials)…
Using devise and an alternate registrations_controller:
Controller:
class RegistrationsController < Devise::RegistrationsController
before_filter :get_teams
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
respond_with resource, :location => redirect_location(resource_name, resource)
else
set_flash_message :notice, :inactive_signed_up, :reason => resource.inactive_message.to_s if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords(resource)
respond_with_navigational(resource) { render_with_scope :new }
end
end
...
private
def get_teams
@teams = Team.all.map{ |p| [p.team_name, p.id]}
end
end
registrations.html.erb:
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.submit "Sign up" %></p>
<% end %>
I’m assuming that you redirect to the countdown with a before filter… something like:
if so, you just need to put a skip_filter on the registration controller