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