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
3
votes
3 answers

Rails: Passing local variables from Controller to View

I was trying to pass a local variable from controller to a view: # pages_controller.rb def my_method render template: "pages/new_page", message: @message end # new_page.html.erb <% if message %> Do something <% else %> Do something else <%…
3
votes
2 answers

Where to put OAuth logic?

I'm using Zend Framework in a project, and I'm creating a controller only for authentication. In this project we'll accept that a user signs up through a account of other sites like facebook, twitter, myspace, etc.. For this we will be using OAuth.…
jonathancardoso
  • 11,737
  • 7
  • 53
  • 72
3
votes
1 answer

Rails - Nested Objects Deletion

I want to delete the nested object book, that is owned by a user. In the user#show page appears all the books related to that user. Besides each book there is a link to delete it. Here is my code: routes.rb: resources :users do resources :books,…
3
votes
1 answer

Why ActionController::Metal leaks memory?

I have a following class: class Myclass < ActionController::Metal def myaction huge_object.do_something # etc. end private def huge_object @obj ||= begin # allocate and initialize a ~10MB object end end end What I…
Roman
  • 13,100
  • 2
  • 47
  • 63
3
votes
3 answers

ActionController::ParameterMissing: param is missing or the value is empty:

so i know that there´s a lot of questions like that, but none had answered my questions and solved my problem. So, I am with this problem for about a week and I can´t solve it! I am really new to ruby on rails, but i´ve tried tried everything. I…
Gustavo Pires
  • 31
  • 1
  • 5
3
votes
1 answer

Working with and Testing Rails ActionController's respond_with

Apologies in advance for the verbosity of this question. If you bear with me I think you'll find it's actually quite simple...just hard for me to explain given my limited Rails domain knowledge. Given this comment in an ActionController commit…
Meltemi
  • 37,979
  • 50
  • 195
  • 293
3
votes
1 answer

Rails controller manually sanitize parameters

Suppose my views need to pass some params that are absolutely not related to a model. What are the best ways to sanitize the input in the controller ? Eg - Validate inclusion of a parameter in a string array : display_type param that sets whether…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
3
votes
1 answer

How to check if there is any file field in rails request parameters

I am making a logging system which keeps track of all the request the web server is getting. How do I check if any of the requests contain any file i.e. any file upload action?
Rajesh Paul
  • 6,793
  • 6
  • 40
  • 57
3
votes
1 answer

Adding a parameter programatically for Rails 5.1 and newer

I have a couple of before_actions in my project that will set/merge some additional parameters before calling REST actions. This lets me override some basic gems methods with minimal customization. However, I have been getting this deprecation…
3
votes
1 answer

SqlSessionStore in Rails 3

I am migrating an existing application from Rails 2 to Rails 3. In the old environment file, SqlSessionStore was set up with: ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:database_manager =>…
jrdioko
  • 32,230
  • 28
  • 81
  • 120
3
votes
2 answers

How to determine which view to render in a controller action

Okay, I have a few different of ideas of how I would achieve this, but thought I would ask here in case someone has a better solution. I have a SessionsController that has a login view and a widget_login view. I was wondering how to go about…
John Dyer
  • 1,221
  • 1
  • 9
  • 13
3
votes
4 answers

Merge ActionController::Parameters with rails 5

In rails 4, I can merge! StrongParams, but since rails 5 (beta1) merge! is not available. Which is the best way to do that in a controller params = ActionController::Parameters.new({ name: 'Francesco', age: 22, …
3
votes
1 answer

Why does render and redirect not stop execution in a Rails app?

I have a use case question. In Rails 4.1 if you run a controller method and have redirect_to or render at some point in your method you are still allowed to continue execution at that point. Sometimes this results in a…
nobody
  • 7,803
  • 11
  • 56
  • 91
3
votes
1 answer

Default serializer render options in Rails controller

I am using Active Model Serializers in a rails project and have a user object that needs to be passed in from the controller to the serializer like this: # Note the 'user:' option that will be accessible inside # the serializer with…
Rick
  • 8,366
  • 8
  • 47
  • 76
3
votes
2 answers

How to render js template from module included in controller?

I have an action in a controller concern, which gets included in a controller. This action does not render a js.erb file as specified under a respond_to block. How do I properly get an action in a controller concern to successfully render a js.erb…
ahnbizcad
  • 10,491
  • 9
  • 59
  • 85