Questions tagged [actionview]

For questions about Action Views, HTML and Ruby templates used in Ruby on Rails

HTML and Ruby templates used in .

Action View is the View part of for , and is a part of the Ruby-On-Rails Action Pack.

490 questions
5
votes
1 answer

Why rails_admin route only work in link_to and not in 'render'

I am trying to use rails_admin route in two ways = link_to "Users", rails_admin.index_path(:model_name => 'user') = render rails_admin.index_path(:model_name => 'user') First one works fine, when click on the 'Users' link it navigate to the…
Achaius
  • 5,904
  • 21
  • 65
  • 122
5
votes
2 answers

How to prevent Rails from Action View logging in production

In rails 3.2.0,is it possible to turn off rails logging for rendering of views in ActionView:: LogSubscriber in production environment. Currently only way i found to supress is to monkey patch it and increase the log level to debug in the below way.…
Phani
  • 1,704
  • 3
  • 13
  • 18
5
votes
2 answers

Custom variable in Rails view filename

By default, Rails can find views with the format, locale and template language in the filename (so I can create index.de.json.erb) Is it possible to add another, custom parameter to the view's filename? I would like to pass the current subdomain, so…
user1105595
  • 591
  • 2
  • 8
  • 20
4
votes
1 answer

What's the right way to make new methods available to views from a Rails Gem?

If I want to create a new rails gem that adds methods to Rails views what is the right way to do this? Is it to extend ActionView::Base? Would it involve ApplicationHelper in some way?
Inc1982
  • 1,955
  • 1
  • 18
  • 32
4
votes
4 answers

render default template when requested template is missing in Rails

For a plugin I want to hack the following feature into Rails: When a (partial) template does not exist (regardless of the format) I want to render a default template. So say I call an action 'users/index' if users/index.html.erb does not (or other…
Jeroen van Dijk
4
votes
2 answers

Sharing a partial from a different namespace

rails 6.1 I am wanting to reference a partial in app/views/shared/ from another namespace. # app/views/something/index.html.erb <%= render partial: 'shared/my_partial' %> # looks for app/views/shared/_my_partial.html.erb #…
Tony Beninate
  • 1,926
  • 1
  • 24
  • 44
4
votes
2 answers

Implementing Rails 3 template handlers

It appears there's not much documentation on Rails template handlers. There's the included handlers, like RJS, ERB, and Builder, which offer some assistance. I'm trying to implement my own, and I've succeeded, albeit with a bit of weird code, or…
Ivan
  • 97,549
  • 17
  • 50
  • 58
4
votes
1 answer

How to trim leading whitespace with `<%=` in ERB templates in Rails that end up in `pre` elements?

(As far as I have researched here, this is not a duplicate question. Trimming spaces -- often trailing newlines -- is being discussed for <%- or -%>, but not for <%=. It could be a minor defect in Erubi template engine as well, the one being used by…
Jochem Schulenklopper
  • 6,452
  • 4
  • 44
  • 62
4
votes
0 answers

Not able to getExtras from Intent obtained from ACTION_VIEW

I am trying to send some Extras in my intent with action as ACTION_VIEW but somehow i am not getting it in the target Activity. I tried putting extras both in bundle and without bundle(directly in intent object itself.) Here is the Sample Code: …
Amritpal Singh
  • 984
  • 2
  • 14
  • 33
4
votes
1 answer

Getting undefined method content_for()

my mac just broke and I had to migrate to an Ubuntu machine. I am working on an app that is already on production on an Ubuntu machine as well. I cloned this app into my new machine and all the view helpers seems to go missing, btw I am ussing HAML.…
Macario
  • 2,214
  • 2
  • 22
  • 40
4
votes
3 answers

How to make SearchView on Toolbar always expanded?

I already define setIconified() and setIconifiedByDefault() to false but the SearchView menu item is not expanding by default. Here's how I implemented it: View customTitle = getLayoutInflater().inflate(R.layout.toolbar_custom_title,…
Earwin delos Santos
  • 2,965
  • 7
  • 20
  • 29
4
votes
2 answers

Rails ApplicationHelper Escaping HTML without return statement

When I write module ApplicationHelper def flash_helper flash.each do |key, msg| content_tag :div, msg, :class => key ## "
" + msg + "
" end end end I do not get anything unless I return the…
Maletor
  • 43
  • 2
4
votes
2 answers

How do I access "assigns" after "render :template => ..."?

I have an error handling method in my ApplicationController: rescue_from ActiveRecord::RecordNotFound, :with => :not_found def not_found(exception) @exception = exception render :template => '/errors/not_found', :status => 404 end In…
James A. Rosen
  • 64,193
  • 61
  • 179
  • 261
4
votes
1 answer

Give a 404 instead of a 500 error for missing templates

I have a Rails 3.0 app (working on a 3.2 upgrade) and whenever someone requests a template that doesn't exist it gives a 500 error in production. For instance mysite.com/blog_posts/532 sends the post with ID 532 back as HTML no problem, but if for…
John
  • 3,430
  • 2
  • 31
  • 44
4
votes
1 answer

How to render the same 404 page for all unknown requests, including images, in Rails 3.2 without specifying each file format individually?

We use the following catch-all route in routes.rb for 404s: # Catches all 404 errors and redirects match '*url' => 'default#error_404' But this generates a 500 internal server error below because we don't specifically catch PNG formats in…
Crashalot
  • 33,605
  • 61
  • 269
  • 439