Tag: flash message

为什么从null_session动作重定向不支持rails中的flash

我有一个实际上用作来自我的payment gateway的return-url的动作。 因此,为了使它工作,我设置 protect_from_forgery with: :null_session, only: [:verify_payment] def verify_payment data={} params.each do |name, value| data[name]=value end booking=Booking.find(params[‘booking’]) if booking.charge_card(data) redirect_to booking_confirmation_path(booking: data[“booking”]), success: “these wont show” else redirect_to booking_summary_path(booking_id: data[“booking”]), error: “these wont show” end end 有人可以告诉我闪光灯为什么不能redirect ? flash.empty? 重定向后会返回true ..为什么? 但如果我渲染它会工作..

用于#<ActionDispatch :: Request的未定义方法`flash'

我有Ruby on Rails 3的东西 我尝试这个简单的代码 def index flash[:notice] = “ok” respond_to do |format| format.html # index.html.erb end end 这是行不通的 NoMethodError in DashboardsController#index undefined method `flash’ for # 当我尝试 redirect_to :some_in, :notice => “ok” 在其他地方(在some_controller.rb中),然后打印这个:.erb中的通知我有相同的错误,未定义的方法`flash’ 我坚持这个。 我使用谷歌搜索它,但它没有帮助。

如何使用Twitter Bootstrap Rails gem定义Flash通知

我试图在控制器中设置闪存通知,但似乎我只能定义:通知。 当我尝试定义:errors或flash [:errors]时,我遇到了一堆错误。 我目前有这个工作,但所有的消息显然是一个通知类型,而不是错误或警告。 我想知道如何设置错误或警告而不是通知。 我正在使用rails 3.2和twitter bootstrap rails gem 在application.html.erb中 在manuals_controller.rb class ManualsController < ApplicationController def create respond_to do |format| format.html { redirect_to root_url, notice:'MyManual was successfully created.' } end end end

在Rails中,如何在i18n语言环境文件中指定默认的flash消息

我知道i18n语言环境文件中有一些预设结构,以便Rails自动提取值。 例如,如果要为新记录设置默认提交按钮文本: # /config/locales/en.yml en: helpers: submit: create: “Create %{model}” user: create: “Sign Up” 使用此设置,在视图中将产生以下结果: # /app/views/things/new.html.erb #=> Renders a submit button reading “Create Thing” # /app/views/users/new.html.erb #=> Renders a submit button reading “Sign Up” 因此,Rails使用预设层次结构来获取不同模型的提交按钮文本。 (也就是说,你不必告诉它在使用f.submit时要获得哪些i18n文本。)我一直试图找到一种方法来使用flash通知和警报。 是否有类似的预设结构来指定默认的Flash消息? 我知道您可以指定自己的任意结构,如下所示: # /config/locales/en.yml en: controllers: user_accounts: create: flash: notice: “User account was successfully created.” # /app/controllers/users_controller.rb def […]

Rails flash中的link_to()

当用户在我的Rails应用程序上登录失败时,我想将它们指向密码重置页面: flash[:notice] = “Login failed. If you have forgotten your password, you can #{link_to(‘reset it’, reset_path)}” 但是,我不能在控制器中使用link_to。 如果不混合使用控制器和视图逻辑,最好的方法是什么? 我最好的猜测是闪光灯是错误的地方,但我很感激任何输入。