class Object
Constants
- Jbuilder
Public Instance Methods
Source
# File lib/jbuilder/jbuilder_template.rb, line 202 def _cache_key(key, options) name_options = options.slice(:skip_digest, :virtual_path) key = _fragment_name_with_digest(key, name_options) if @context.respond_to?(:combined_fragment_cache_key) key = @context.combined_fragment_cache_key(key) else key = url_for(key).split('://', 2).last if ::Hash === key end ::ActiveSupport::Cache.expand_cache_key(key, :jbuilder) end
Source
# File lib/jbuilder/jbuilder_template.rb, line 215 def _fragment_name_with_digest(key, options) if @context.respond_to?(:cache_fragment_name) @context.cache_fragment_name(key, **options) else key end end
Source
# File lib/jbuilder/jbuilder_template.rb, line 227 def _is_active_model?(object) object.class.respond_to?(:model_name) && object.respond_to?(:to_partial_path) end
Source
# File lib/jbuilder/jbuilder_template.rb, line 223 def _partial_options?(options) ::Hash === options && options.key?(:as) && options.key?(:partial) end
Source
# File lib/jbuilder/jbuilder_template.rb, line 265 def _render_active_model_partial(object) @context.render object, json: self end
Source
# File lib/jbuilder/jbuilder_template.rb, line 244 def _render_explicit_partial(name_or_options, locals = {}) case name_or_options when ::Hash # partial! partial: 'name', foo: 'bar' options = name_or_options else # partial! 'name', locals: {foo: 'bar'} if locals.one? && (locals.keys.first == :locals) options = locals.merge(partial: name_or_options) else options = { partial: name_or_options, locals: locals } end # partial! 'name', foo: 'bar' as = locals.delete(:as) options[:as] = as if as.present? options[:collection] = locals[:collection] if locals.key?(:collection) end _render_partial_with_options options end
Source
# File lib/jbuilder/jbuilder_template.rb, line 231 def _set_inline_partial(name, object, options) value = if object.nil? [] elsif _is_collection?(object) _scope{ _render_partial_with_options options.merge(collection: object) } else locals = ::Hash[options[:as], object] _scope{ _render_partial_with_options options.merge(locals: locals) } end set! name, value end
Source
# File lib/generators/rails/templates/controller.rb, line 56 def destroy @<%= orm_instance.destroy %> respond_to do |format| format.html { redirect_to <%= index_helper %>_url, notice: <%= %("#{human_name} was successfully destroyed.") %> } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_<%= singular_table_name %> @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> end # Only allow a list of trusted parameters through. def <%= "#{singular_table_name}_params" %> <%- if attributes_names.empty? -%> params.fetch(<%= ":#{singular_table_name}" %>, {}) <%- else -%> params.require(<%= ":#{singular_table_name}" %>).permit(<
Source
# File lib/generators/rails/templates/controller.rb, line 43 def update respond_to do |format| if @<%= orm_instance.update("#{singular_table_name}_params") %> format.html { redirect_to <%= show_helper %>, notice: <%= %("#{human_name} was successfully updated.") %> } format.json { render :show, status: :ok, location: <%= "@#{singular_table_name}" %> } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity } end end end # DELETE <%= route_url %>/1 or <%= route_url %>/1.json def destroy @<%= orm_instance.destroy %> respond_to do |format| format.html { redirect_to <%= index_helper %>_url, notice: <%= %("#{human_name} was successfully destroyed.") %> } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_<%= singular_table_name %> @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> end # Only allow a list of trusted parameters through. def <%= "#{singular_table_name}_params" %> <%- if attributes_names.empty? -%> params.fetch(<%= ":#{singular_table_name}" %>, {}) <%- else -%> params.require(<%= ":#{singular_table_name}" %>).permit