ruby-on-rails

    0热度

    1回答

    我需要在帖子表中存储user_id(对于每个新帖子)。我从表单中将user_id作为hidden_​​field传递。从控制器本身获取user_id的替代方法是什么? 在控制器 def create @post [email protected](post_params).save end 桩模型 class Post < ApplicationRecord belong

    0热度

    2回答

    我想写一些基本的Rails测试代码,使用默认的轨道测试框架。我的应用程序是一个简单的论坛,在这里用户可以发布主题,发表评论等 我试图测试论坛(即线程)控制器,那就是: forums_controller_test.rb require 'test_helper' class ForumsControllerTest < ActionController::TestCase test "ind

    1热度

    5回答

    我有评论和回复。 评论的has_many回复 的routes.rb resources :comments do resources :replies end 当我打开的意见/指数,然后选择的意见/节目我打印所有的,都与该评论的答复信息。 <% @comment.replies.each do |reply| %> 我也可以创建另一个答复。所有这些正常工作。 问题出现在我决定编

    0热度

    1回答

    我搜索了整个网络寻找解决此错误的方法。但它不会让步。根据我的知识,我安装了所有的库和依赖项,甚至卸载了ruby和nokogiri并重新安装。但是这个错误仍然存​​在。 Gem files will remain installed in /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/nokogiri-1.4.7 for ins

    0热度

    1回答

    我目前正试图创建具有轨道新的应用程序,希望在我的应用程序目录下安装宝石,得到了以下信息: [email protected]:/dev/movies-forum# bundle install --path vendor/bundle Don't run Bundler as root. Bundler can ask for sudo if it is needed, and install

    1热度

    1回答

    我想添加与模型错误的散列闪存和重定向后。这是控制器: def update current_user.update_attributes(user_params) if current_user.errors.any? flash.keep[:errors] = current_user.errors.messages end byebug

    -1热度

    5回答

    如果我收到的输入,如: up 1, down 2, down 3, left 5 我这个保存为一个数组,它会给我 ["up 1", " down 2", " down 3", " left 5"] 但我需要删除空格之前向下和向左! 任何想法?

    3热度

    1回答

    我在我的Rails 5.1的项目USNG Bootstrap4,我设置了引导与 gem 'bootstrap', '~> 4.0.0.beta2.1' 我遵守所有的指示和导航栏添加的,但它看起来像移动版本,但我的桌面大小是1600px +宽。 什么问题? 这里的布局和导航栏 <!DOCTYPE html> <html lang="en"> <head> <title>CS

    -1热度

    1回答

    试图删除回复 <% @comment.replies.each do |reply| %> <td><%= link_to 'Destroy', comment_replies_path(reply), method: :delete, data: { confirm: 'Are you sure?' }%></td> 我收到以下错误 No route matches [DELETE] "/

    0热度

    1回答

    我在我的应用程序中使用了不同的语言,我正在使用此模式:/:locale/some-action。我的大部分线路都在此范围内:locale - routes.rb中: scope "(:locale)", locale: /fr|en/ do root to: 'home#index' get 'contacts', to: 'contacts#index' end get