Rails: Make views editable by end-users?
Date : March 29 2020, 07:55 AM
it helps some times You are describing a CMS. Check out BrowserCMS and RadiantCMS. In short, you need to extract out parts of the page that are editable, and store them somewhere, typically the DB. You can have users edit those parts of the page via your typical web forms. Extra points for ajax/in-place editing, but other than that there's not much magic to it. This railscast may also be useful if you don't need a full blown CMS.
|
how to make a variable seen in all views - rails
Date : March 29 2020, 07:55 AM
hope this fix your issue I doubt you actually need it to be accessible in all views. But you can put @random_quote = Quote.find(:random) under a method that is called with a before_filter in your ApplicationController. It will then be accessible everywhere. Like so: before_filter :get_random_quote
def get_random_quote
@random_quote = Quote.find(:random)
end
|
What's the right way to make new methods available to views from a Rails Gem?
Date : March 29 2020, 07:55 AM
I wish this help you Many gem authors create a module that defines their view helper methods and then includes them in ActionView::Base. module MyGem
module ActionViewExtensions
module MyHelpers
def my_view_helper
# ...
end
end
end
end
# You can do this here or in a Railtie
ActionView::Base.send :include, MyGem::ActionViewExtensions::MyHelpers
|
In Rails, how to make :mobile views to fallback default views when not found?
Date : March 29 2020, 07:55 AM
I wish this helpful for you assume you got a mobile_request? controller instance method to detect mobile requests, then you should be able to set format fallback chains: # application_controller.rb
before_filter :set_request_format, :set_format_fallbacks
respond_to :html, :mobile # etc
def set_request_format
request.format = :mobile if mobile_request?
end
def set_format_fallbacks
if request.format == :mobile
self.formats = [:mobile, :html]
end
end
|
Rails: How to make small changes in different views
Date : March 29 2020, 07:55 AM
wish of those help Is it possible to make small changes in different views? , You can use controller.action_name. <% if controller.action_name == 'show' %>
<%= l(e.start_at) %>-<%= l(e.end_at) %> # display only show.html.erb
<% end %>
|