Questions tagged [applicationcontroller]
61 questions
2
votes
1 answer
How to override a render to create a custom "render :my_format => argument" in rails 2.3(.5)?
I would like to create a custom render as specified in title.
For instance, I have my controller:
class MyController < ApplicationController
def index
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml =>…

Rafael
- 1,126
- 11
- 16
2
votes
2 answers
Is it possible to define ActionController::Base in many different controllers?
If you had an OrdersController, could you define the class like this?
class OrdersController < ActionController::Base
# stuff
end
When I generate a Rails scaffold, the only place this seems to be defined is in the…

Jesse Samson
- 133
- 1
- 12
2
votes
2 answers
Redirect to a specified URL after a POST in Rails
So often I have a form in some webpage that the user submits to a POST, PUT or DELETE action in Rails where I want it to redirect to a specified URL if the submission was a success. I typically make a hidden extra parameter called to with a path…

at.
- 50,922
- 104
- 292
- 461
2
votes
1 answer
Rails: side effect of including the same filter twice
I have a gem I'm developing that is based around using filters on ApplicationController. It's basically for logging, and one of the modules defines an around filter like so:
module LogExceptionFilter
self.included(base)
base.around_filter…

user969472
- 33
- 2
2
votes
2 answers
Rails - how to run method only first time, when user come to my page
I have lots of data in database and I wanna make a statistics from them. Lots of data = thousands rows in table, and I wanna get the daily, weekly, monthly (for every month) stats... just detailed statistics.
The problem is, that the getting these…

user984621
- 46,344
- 73
- 224
- 412
1
vote
1 answer
How to redirect to another format of the same controller action?
I've got this index method in my TasksController:
def index
@tasks = current_account.tasks
@count = @tasks.length
respond_to do |format|
format.html do
...
end
format.zip do
if @count > 100
flash[:notice] =…

Tintin81
- 9,821
- 20
- 85
- 178
1
vote
1 answer
How to handle Rails joins table relationship removals?
I am creating an application which manages Users and Tasks. The relationship between these two models is many-to-many, as a user can have many tasks assigned to them, and a task can have many users assigned to it. For this reason, I created a…

Brandon Woodruff
- 123
- 1
- 8
1
vote
1 answer
Using "ApplicationController.new.render_to_string" in a Rails api app (config.api_only = true)
I have a Rails 5 app build as an api app:
# config/application.rb
module MyApp
class Application < Rails::Application
config.api_only = true
end
end
In one of my controller actions I need to render some Ruby flavoured html, and then serve…

JohnSmith1976
- 536
- 2
- 12
- 35
1
vote
1 answer
Define a variable in application controller, but do not use it on pages, where content_for tag won't be present
In my app I will have an ad banner, but it won't be displayed on every page. So, I've defined the ad banner in application controller:
before_action :set_ad_banner
def set_ad_banner
@ad_banner = Advertising
…

Alex Zakruzhetskyi
- 1,383
- 2
- 22
- 43
1
vote
1 answer
current_page? inside controller
Is there any easy way of using something like current_page?method
from ActionView::Helpers::UrlHelper inside controller?
I have routing like:
resources :addresses
resources :mailing_addresses, :controller => 'addresses'
And I would like to do a…

Sasha
- 20,424
- 9
- 40
- 57
1
vote
1 answer
ApplicationController error in rails when trying to visit web page -- wrong argument type Class (module expected)
I'm working with a rails application I've been using for a very long time that has not had a front end prior to this point. By long time I mean over a year. I use it to run console-based database stuff.
I'm trying to put a simple front-end on it…

boulder_ruby
- 38,457
- 9
- 79
- 100
1
vote
1 answer
rails application controller method is undefined in children
I'm having a slight issue.
I have the following controllers set out like so:
class ApplicationController < ActionController::Base
attr_accessor :perms
helper_method :set_permissions
def set_permissions *permissions
self.perms = permissions
…

Thermatix
- 2,757
- 21
- 51
1
vote
1 answer
Why can't rails3 find ApplicationController when it is in my application
In a Rails3 Application I keep getting
..gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:459:in 'load_missing_constant': uninitialized constant ApplicationController (NameError)
Even though app/controllers/application_controller.rb…

Laurie Young
- 136,234
- 13
- 47
- 54
1
vote
2 answers
Ruby ApplicationController function call in ActionMailer
I'm sending out emails to users and I need to call a function I have in my ApplicationController. Seems simple enough, but I cannot for the life of me find any documentation on how to to this. I can access ApplicationHelper functions just fine, but…

Ralph Haynes
- 83
- 10
1
vote
1 answer
application_controller.rb or new?
I'm new to Ruby on Rails, learning it to create a new SaaS I'm working on. Whilst I'm able to write some RoR, I don't know the majority of conventions for the language.
My question is, for the front website (seen by non-registered users) should I…

James
- 5,137
- 5
- 40
- 80