<%= render partial: "nav", selected: "about"}%> <%= render partial: "nav", local_variables: {selected: "about"} %> <%= render partial: "nav", locals: {selected: "about"} skip_before_action :get_feature skip :get_feature, except: [] prevent_action :get_feature :redis_cache_store form_tag और form_for के बीच एक अंतर कोई सही विवरण है?form_tag मेथड बुनियादी फॉर्मों के लिए है, जबकि form_for मेथड फ़ाइल अपलोड शामिल करने वाले मल्टीपार्ट फ़ॉर्मों के लिए है। form_tag मेथड HTTP अनुरोधों के लिए है, जबकि form_for मेथड AJAX अनुरोधों के लिए है। form_tag मेथड आमतौर पर अपने पहले तर्क के रूप में एक URL की उम्मीद करता है, जबकि form_for मेथड आमतौर पर एक मॉडल ऑब्जेक्ट की उम्मीद करता है। form_tag मेथड को रनटाइम में मूल्यांकन किया जाता है, जबकि form_for मेथड पूर्वानुक्रमित और कैश किया जाता है। before_action (पूर्व में जाना जाता था before_filter) क्या है?ActiveSupport::Concern RailsHelper.CommonClass ActiveJob::Mixin ActiveSupport::Module PUT और PATCH REST HTTP क्रियाएँ हैं?put :items, include: patch put 'items', to: 'items#update' match 'items', to 'items#update', via: [:put, :patch] match :items, using: put && patch [ ] Product.where("name = #{@keyword}")
Product.where("name = " << @keyword} Product.where("name = ?", @keyword Product.where("name = " + h(@keyword) class Document < ActiveRecord::Base belongs_to :documentable, polymorphic: true end class Product < ActiveRecord::Base has_many :documents, as: :documentable end class Service < ActiveRecord::Base has_many :documents, as: :documentable end
:type के लिए एक स्तंभ शामिल होगा। :documentable_id और :documentable_type के लिए स्तंभ शामिल होंगे। :documentable और :type के लिए स्तंभ शामिल होंगे। :polymorphic_type के लिए एक स्तंभ शामिल होगा। my_model.errors[:field] my_model.get_errors_for(:field) my_model.field.error my_model.all_errors.select(:field) id प्राथमिक कुंजी है, तो कौन सा वाक्य "लास्ट_नेम" केवल एक ऑब्जेक्ट वापस करेगा जिसका last_name "Cordero" है?-------------------------------
| id | first_name | last_name |
|----|------------|-----------|
| 1 | Alice | Anderson |
| 2 | Bob | Buckner |
| 3 | Carrie | Cordero |
| 4 | Devon | Dupre |
| 5 | Carrie | Eastman |
-------------------------------
User.where(first_name: "Carrie") User.not.where(id: [1, 2, 4, 5]) User.find_by(first_name: "Cordero") User.find(3) <%= select_tag(@products) %> <%= collection_select(@products) %> <select name="product_id"> <%= @products.each do |product| %> <option value="<%= product.id %>"/> <% end %></select> <%= collection_select(:product, :product_id, Product.all, :id, :name) %> address के लिए संदेश "यह पता अवैध है" को परिभाषित करेंगे?model.errors = This address is invalid errors(model, :address) << "This address is invalid" display_error_for(model, :address, "This address is invalid") model.errors[:address] << "This address is invalid" product_path(@product) को देखते हुए, कौन सा वाक्य "गलत" होने की संभावना है?class DocumentsController < ApplicationController before_action :require_login def index @documents = Document.visible.sorted end end
:index को before_action में नहीं दिया गया है। require_login मेथड स्वचालित रूप से उपयोगकर्ता को लॉग इन कर लेगा, इससे पहले अनुक्रम क्रिया को चलाने से पहले। require_login मेथड render या redirect_to को बुलाता है, तो अनुक्रम क्रिया नहीं चलेगी। render partial: 'shared/menu', cached: true render_with_cache partial: 'shared/menu' render partial: 'shared/menu' render partial: 'shared/menu', cached_with_variables: {} े के लिए किया जाता है।
build new create save coffee_orders है। उस तालिका का ActiveRecord मॉडल क्या नाम होगा ताकि उसे उपयोग किया जा सके?CoffeeOrders Coffee_Orders Coffee_Order CoffeeOrder