让他只能发1篇文章?
def index
@restaurants = Restaurant.all
end
def new
@restaurant = Restaurant.new
render :layout => "users"
end
def show
@restaurant = Restaurant.find(params[:id])
end
def create
@restaurant = Restaurant.new(restaurant_params)
if @restaurant.save
flash[:success] = 'Project was saved!'
redirect_to root_path
else
render 'new'
end
end
没有足够的信息。你现在在控制器中有什么,你如何验证用户,在 cancancan/pundit/analogues 中是否有权限检查。
这是前额的一般解决方案。在带有帖子的控制器中写: