私はレールに不慣れで、最初のアプリケーションを開発するのは難しくなります。なぜなら、あなたは物事を知っているが、それらを行う方法がわからないからです。
「ファンシーボックス」jqueryを使用して、ポップアップのように表示されるボックスに登録フォームを設定しました。一部のユーザーがサインアップに失敗した場合、ページが検証エラーでボックスに残り、ユーザーが正しくサインアップしたときにホームページにリダイレクトしたいのですが、これはできません:
デバイスメソッドをオーバーライドする私のコントローラー:
def setup
@society = Society.new
end
# GET /resource/sign_up
def new
super
end
# POST /resource
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" 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
render action: new
end
end
protected
def after_sign_up_path_for(resource)
'/vetrina/index' #my homepage
end
そしてフォーム:
<%= simple_form_for @society, :html => { :class => 'form-horizontal' } do |f| %>
<fieldset>
#all the inputs are here
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to 'Cancel', "#", :class => 'btn' %>
</div>
</fieldset>
何か助けはありますか?