小编Oli*_*ier的帖子

如何在rails3中呈现编辑视图和发布flash消息

在我的帐户控制器中,我想在保存更改并显示闪存通知后显示(渲染,重定向?)编辑视图.

 def update
    @account = Account.find(params[:id])

    respond_to do |format|
      if @account.update_attributes(params[:account])
        format.html { redirect_to(@account, :notice => 'Account was successfully updated.') }

      else
        format.html { render :action => "edit" }
      end
    end
  end
Run Code Online (Sandbox Code Playgroud)

view ruby-on-rails-3

32
推荐指数
3
解决办法
4万
查看次数

如何在注册Rails3和Devise后添加回调

如何添加回调以为注册用户创建帐户.

设计文件(registrations_controller.rb)在控制器/设计下我的用户模型有has_many:accounts关系(并且帐户模型有belongs_to:user)

首先我不知道在哪里添加回调(什么文件?)

那么,如何使用注册用户的正确user_id自动创建一个新帐户?

提前致谢.

callback devise ruby-on-rails-3

9
推荐指数
2
解决办法
8705
查看次数

什么是用devise破坏注册的途径

我正在尝试添加链接,以便用户可以销毁他/她自己的帐户.我正在使用内置注册类.

在我看来,我已经<%= link_to 'Destroy', current_user, :confirm => 'Are you sure you want to destroy your account?', :method => :delete %>通过示例指向localhost:3000/users/4

首先,是使用正确的链接吗?其次,如何重定向到根路径,因为目前看起来它试图重定向到id为4的用户(并且因为它受到保护而失败).

耙路线给出 DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}

提前致谢.

devise ruby-on-rails-3

8
推荐指数
1
解决办法
1万
查看次数

如何在用户注册Rails3&Devise后创建配置文件

我正在使用配置文件应用程序做一个简单的用户.用户注册并自动登录.到目前为止工作正常.现在,我想在注册成功后创建个人资料,并将用户重定向到他/她的个人资料.

我有一个用户模型和控制器.Devise还创建了注册控制器.我安装了宝石.我复制了设计文件,我计划覆盖创建操作.

首先,无论我在registrations_controller.rb中编辑什么都没有变化.

class Devise::RegistrationsController < ApplicationController
 prepend_before_filter :require_no_authentication, :only =>
[ :new, :create, :cancel ]
 prepend_before_filter :authenticate_scope!, :only =>
[:edit, :update, :destroy]
 include Devise::Controllers::InternalHelpers
Run Code Online (Sandbox Code Playgroud)

其次,如何插入配置文件创建步骤?

def create
   build_resource

   if resource.save
     if resource.active?
       set_flash_message :notice, :signed_up
       sign_in_and_redirect(resource_name, resource)
     else
       set_flash_message :notice, :inactive_signed_up, :reason =>
resource.inactive_message.to_s
       expire_session_data_after_sign_in!
       redirect_to after_inactive_sign_up_path_for(resource)
     end
   else
     clean_up_passwords(resource)
     render_with_scope :new
   end
 end
Run Code Online (Sandbox Code Playgroud)

我想补充一下

 current_user.create_profile under is resource.active?
Run Code Online (Sandbox Code Playgroud)

你们怎么解决这个问题?

profile controller devise ruby-on-rails-3

5
推荐指数
1
解决办法
4052
查看次数

如何使用rails3创建范围以获取最后十个事务

尝试将范围添加到我的事务模型以返回created_at的最后10个事务

scope ruby-on-rails-3

5
推荐指数
2
解决办法
7755
查看次数

标签 统计

ruby-on-rails-3 ×5

devise ×3

callback ×1

controller ×1

profile ×1

scope ×1

view ×1