Questions tagged [actioncontroller]

ActionController is the main controller class in Ruby on Rails.

ActionController is the main controller class in Ruby on Rails.

424 questions
1
vote
1 answer

Is it possible to stop Rails from rendering views for actions not defined in controllers?

Following this question, I'd like to know if there is a way to override that new rails behaviour. I run into a security issue with a forgotten view, that was suddenly exposed although the action was not defined in my Controller. I think it'd be…
dgilperez
  • 10,716
  • 8
  • 68
  • 96
1
vote
2 answers

Receiving AbstractController::DoubleRenderError when using authenticate_or_request_with_http_basic()

I have a working controller action that breaks when I add a call to authenticate_or_request_with_http_basic at the beginning of the block. Here is the non-functioning action code: def index authenticate_or_request_with_http_basic do |username,…
1
vote
1 answer

ActionController Mixin

How could I create a mixin for action controller, which does something like: layout Proc.new { |controller| if controller.request.xhr? 'minimal' else 'application' end } (I can't subclass ApplicationController, because I'm using a gem…
mahemoff
  • 44,526
  • 36
  • 160
  • 222
1
vote
3 answers

How to retrieve the controller class from within a view/helper in Rails 3?

I know about controller_name returning a string containing the controller's name but how can I retrieve the controller class (or object) from within a helper? EDIT: The solution should also work when the controller is namespaced (eg.…
Kostas
  • 8,356
  • 11
  • 47
  • 63
1
vote
4 answers

uninitialized constant ActionController::Dispatcher::MiddlewareStack

I installed some new gems for testing and ran into an uninitialized constant ActionController::Dispatcher::MiddlewareStack error. I followed the instructions on the gem rdocs-specified the gem dependency in my environment.rb file and then ran rake…
sutee
  • 12,568
  • 13
  • 49
  • 61
1
vote
0 answers

NameError for ActionMailer within ActionController

I'm on Rails 3.0, and I pretty much followed the steps on the API to define a mailer by doing rails generate mailer Notifier Within my controller, I call Notifier.mytemplate(...) When I go to the page, I see an error: uninitialized constant…
1
vote
1 answer

Rendering Rails partial view (with issues reading the Rails API)

I have a jQuery post submitting a form to a controller create action, which works great. If the save was successful I would like the create action to return a different form so the success callback will insert this form. Is this possible? Here's my…
codedog
  • 2,488
  • 9
  • 38
  • 67
1
vote
2 answers

ActionController::RoutingError: No route matches [POST]

require 'test_helper' class MyTest < ActionController::IntegrationTest test "view posts from login page" do visit("/logins/new") find_field('Username').set('abode') find_field('Password').set('efghi') …
Ava
  • 5,783
  • 27
  • 58
  • 86
1
vote
1 answer

NameError uninitialized constant in Jruy/Rails 3

I'm upgrading a project to Rails 3.1 and Jruby 1.6.4 from rails 2.6 I followed the Rails Handbook by Jeremy. Now I'm getting some errors while booting the server. NameError in Adm::AuthController#login uninitialized constant…
1
vote
1 answer

Rails 7 ActionController::UnknownFormat in CommentsController#create respond_to

I have a comments controller that i want to load a partial "create.js.erb" class CommentsController < ApplicationController skip_before_action :verify_authenticity_token def create @comment = Comment.new(comment_params) …
A-laz
  • 55
  • 6
1
vote
1 answer

testing a that Rails controller chooses a layout without rendering the layout

i'd like to stub out render and i'd like to test that a certain layout is chosen bonus catch: in the test env, that layout file will not exist is there a clever way to detect if the controller has selected a layout without rendering, and without…
whatbird
  • 1,552
  • 1
  • 14
  • 25
1
vote
1 answer

How to cache Rails API actions

What is the best and correct approach to do caching for actions? Am I forced to ActionController::Base? Is there another way (keeping ActionController::API present)? Do I have to push caching down to Model layer? I saw that Rails 6 (maybe prior)…
Jan
  • 12,992
  • 9
  • 53
  • 89
1
vote
1 answer

No route matches {:action=>"show", :controller=>"products"}, missing required keys: [:id]

I have a rSpec Controller test which fails the index route will have an :id which does not exist in an index route. I've clean routes: resources :products This is the controller, class ProductsController < ApplicationController before_action…
Jan
  • 12,992
  • 9
  • 53
  • 89
1
vote
2 answers

Why isn't the args parameter used in ActionController::Instrumentation::render?

I am new to Ruby and to Rails, and am trying to understand fully what I'm reading. I am looking at some of the Rails source code, in this case action_controller/metal/instrumentation.rb. def render(*args) render_output = nil self.view_runtime =…
temporary_user_name
  • 35,956
  • 47
  • 141
  • 220
1
vote
1 answer

Rails: How to step-by-step debug a request

I have an ajax request that is causing problems in my Rails 3.0.9 app. I can see the problem in the logs, but I don't have any idea what is triggering it between the ajax call and the render. Here's the log, and the event I don't want with ** beside…
Andrew
  • 42,517
  • 51
  • 181
  • 281