I am building a web app using Ruby on Rails. I am using Mailgun as my mailer for this app. when i sign up using Facebook it works fine but when i try to sign up using email and password , i keep getting this error "554 Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the activation email." I have already authorized the eamil to the Authorized Recipients in mailgun dashboard. …
我正在尝试使用Ruby on Rails在我的应用程序中添加Searchkick gem但是当我在搜索框中键入一个单词时,我的应用程序中出现此错误.我已根据需要安装了elasticsearch和最新版本的java,但错误仍然相同.这是我得到的错误:
PostsController #search中的Faraday :: ConnectionFailed
连接被拒绝 - 连接(2)为"localhost"端口9200
这是我的代码:
终端显示已安装弹性搜索:
终奌站
Warning: elasticsearch-1.7.3 already installed
Run Code Online (Sandbox Code Playgroud)
posts_controller.rb
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
def search
if params[:search].present?
@posts = Post.search(params[:search])
else
@posts = Post.all
end
end
# GET /posts
# GET /posts.json
def index
@posts = Post.all
end
# GET /posts/1
# GET /posts/1.json
def show
end
# GET /posts/new
def new
@post = Post.new
end
# GET /posts/1/edit
def edit
end
# …
Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails ruby-on-rails-3 elasticsearch ruby-on-rails-4
我已经按照指南介绍了如何在我的应用程序的Rails中安装Administrate gem,但我想添加的是只能由我设置管理员的功能.我遵循了Gtihub说明,但我仍然坚持如何将我的电子邮件或任何其他用户电子邮件设置为管理员.这是我到目前为止添加的内容:
控制器/管理/ application_controller.rb
# All Administrate controllers inherit from this `Admin::ApplicationController`,
# making it the ideal place to put authentication logic or other
# before_filters.
#
# If you want to add pagination or other controller-level concerns,
# you're free to overwrite the RESTful controller actions.
class Admin::ApplicationController < Administrate::ApplicationController
before_action :authenticate_user!
before_action :authenticate_admin
def authenticate_admin
redirect_to '/', alert: 'Not authorized.' unless current_user && access_whitelist
end
private
def access_whitelist
current_user.try(:admin?) || current_user.try(:door_super?)
end …
Run Code Online (Sandbox Code Playgroud) 如何更改Ruby on Rails中提交按钮的文本?我尝试添加标签方法,但它不起作用.
/_form.html.erb
<div class="form-group">
<%= f.submit class: "btn btn-primary" , label: "Click Here"%>
</div>
Run Code Online (Sandbox Code Playgroud)