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
8
votes
2 answers

Ruby on Rails 301 redirection

I added slugs to some of the models, but because of SEO I need to do 301 redirection from old links: old: http://host.com/foo/1 new: http://host.com/foo/foo_slug question: how to implement 301 redirection in this case? and is it possible to…
xamenrax
  • 1,724
  • 3
  • 27
  • 47
8
votes
2 answers

Why doesn't Rails parameter wrapping include things globbed from the URI?

The docs on parameter wrapping state: Wraps the parameters hash into a nested hash. This will allow clients to submit POST requests without having to specify any root elements. It helpfully elides which parameters hash is being wrapped. The Action…
Asherah
  • 18,948
  • 5
  • 53
  • 72
7
votes
3 answers

Rescue from routing error rails 3.1

How to rescue from RoutingError in rails 3.1 application. If i'm nt mistaken it was possible to use rescue_from RoutingError in application controller but now it's not possible.
roman
  • 5,100
  • 14
  • 44
  • 77
7
votes
1 answer

Rails: How to choose which js file a controller action to render?

I know the fact that by default Rails chooses the javascript file depending on action's name to render: For example if I have def create #Code and Stuff happening here end and here I have create.js.erb which will be ran by default But is…
0bserver07
  • 3,390
  • 1
  • 28
  • 56
7
votes
1 answer

Why controller action should call one model method other than an initial find or new?

I have almost all of the "shared" statements in functions in my model. The problem is that I am getting the following error, when I need to use more then one of these functions in my controller: Controller action should call one model method other…
gotqn
  • 42,737
  • 46
  • 157
  • 243
7
votes
5 answers

One controller, different views for normal users and admins

in my application, I have a "User" model. Each user can have multiple (email) addresses which are defined in the model "Address": Class User < ActiveRecord::Base has_many :addresses def is_authorized(op) # returns true or false end …
cite
  • 778
  • 5
  • 12
6
votes
1 answer

FInding out which before_filters are already set in Rails 3

I have a DSL for controller configuration. The underlying functionality relies on before_filters. To prevent setting the before_filter more than once, I really need to find out whether a before_filter is already set in a Rails 3 controller. Since…
Steffen
  • 61
  • 3
6
votes
1 answer

How to get ActionController::Live streaming working with Thin?

Question Can you use thin with ActionController::Live to implement Server Side Events (SSE) and long polling? If so, how? Context Although the title is a repeat of How to get Rails 4 ActionController::Live streaming working with Thin and Ruby 2?…
fearless_fool
  • 33,645
  • 23
  • 135
  • 217
6
votes
3 answers

What module is needed with ActionController::Metal to be able to pass status code to render?

I have an Api controller using ActionController::Metal on Rails 4.1.6 like this: class Api < ActionController::Metal include AbstractController::Rendering include ActionController::ImplicitRender include ActionController::MimeResponds …
Michael
  • 683
  • 9
  • 21
6
votes
1 answer

Getting Action controller unknown format error- for rails 4 + unobtrusive javascript and AJAX call

Ive got the following setup: uploads_controller.rb: class UploadsController < ApplicationController before_action :set_upload, only: [:show, :edit, :update, :destroy] # GET /uploads def index @uploads = Upload.all …
6
votes
2 answers

Rails best practice for having same form on multiple pages

I am developing an Rails 2.3.1 Web site. Throughout the Web site, I need to have a form for creating Posts on various pages (Home page, Create Posts page, Post listing page, Comment listing page, etc. -- suffice to say this form needs to be on many…
empire29
  • 3,729
  • 6
  • 45
  • 71
6
votes
2 answers

Rails 3.2 - ActiveResource - Using POST/PUT with JSON

I have been looking at this for a while, and am currently at a loss. I have narrowed the problem down to being related to JSON, and that the JSON does not appear to be being sent in a legible format. We were previously using Rails 3.0.7 (where the…
Krista
  • 895
  • 1
  • 6
  • 16
5
votes
2 answers

Transaction Action with Ruby On Rails

I have a complex action inside controller that performs several update queries to the database. How can I make this action acts like transaction without any structural refactoring?
Bogdan Gusiev
  • 8,027
  • 16
  • 61
  • 81
5
votes
3 answers

Transfer only a part of properties in a class in struts' json

Sorry, I really don't know how to summarize the title of this question. So, the title may not be clear. I have an action class which performs some business logic. in the Action Class: class ActionClass extends ActionSupport{ private…
xiaohan2012
  • 9,870
  • 23
  • 67
  • 101
5
votes
3 answers

How to disable rendering the view in ActionController TestCase (Rails 3.0.9)

What's the proper way to disable ActionController::TestCase to actually render the views? Alternatively, what'd be the way to render the view without the layout in the tests? Using rr, I've tried stub(@controller).render { "" } but this broke…
zoli
  • 469
  • 6
  • 17
1 2
3
28 29