I'm working on a fairly traditional forgot password email - I want to email the user a password change token embedded in a link that they can click on in order to change their password. I'm emailing via the traditional ActionMailer.
If I use a normal link_to tag
<%= link_to "click here", :controller => foo, :action => 'bar', :token =>...
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 gems:install and rake gems:unpack.
I also copied over my environment.rb file one line at ...
First post time,
I've been playing around with MVC abit... I have a view which has multiple input fields, some of these fields can be blank on post.
The action method inside the controller for the post looks something like this
public ActionResult Filter(int? id, string firstName, string lastName, bool? isMember)
I've been using the...
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?
...
It seems my rspec route for :controller => 'phones', :action => 'edit' works...it should be 'phones/123/edit', and IS according to rspec tests and rake routes. But when I create a redirect_to expectation, the expectation fails.
Here's the routes test for the url:
it "maps #edit" do
route_for(:controller => "phones", :action ...
I have a gem that uses some of the Rails libs, including action_view and active_controller. Though I require those libs, all tests fail when trying to call some has_text? method, which (as I found out) is part of'rexml/element' lib. Here's what I get:
undefined method `has_text?' for "<b>Hello,<i>world</b></i>":String
Requiring 'rexml...
One of our requirements was that all our url's ended with .html
We've overridden the default_url_options method to add the format to the options
def default_url_options(options={})
options.merge(:format => 'html')
end
This works great in the most part...
but it causes issue with the following routes:
map.home '/', :controller => 'h...
Hello everyone,
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
def is_owned_by(user)
# returns true or false
end
end
Class Addre...
I'm writing a plugin that adds a method to controllers and declares it as a helper method. If it were done statically (rather than through the plugin), it would look something like this:
# in RAILS_ROOT/app/controllers/stuffed_animals_controller.rb
class StuffedAnimalsController < ActionController::Base
private
def bear
'Teddy...
In my routes.rb I've got:
map.connect ':name',
:controller => 'my_classes',
:action => 'show'
And that works perfectly, so a url like this sends params like so:
http://localhost:30000/awesome
Parameters: {"name"=>"awesome"}
But if I have something like this I get this error:
http://localhost:30000/weak.sauc...
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 pages served by a variety of controllers). Each of these pages displays a wide variety of ...
I have an ActionController derived Test which sends a 'post' request to the controller under test with incorrect data. The controller tries to create a new object and save it. The model has validation methods that get triggered on save and they generate a validation error detecting the incorrect data sent by test.
So far so good. Now, c...
I have a submenu placed in my layout wich differs from controller to controller, but not between each controllers method views. What I am currently doing is the following:
<% content_for( :submenu ) do %>
<%= render :partial => 'submenus/correct_submenu' %>
<% end %>
In every view for a method
My applications layout then has this...
Hi all,
I'm trying to use rails nested form_for helper, but I am getting the following error:
BlogPage(#49859550) expected, got Array(#31117360)
Here are my model objects:
class Blog < ActiveRecord::Base
# Table Configuration
set_table_name "blog"
# Model Configuration
belongs_to :item
has_many :blog_pages
accepts_nested_att...
I have the authentication code to be available over several Controllers. So I thought of putting the Authentication code in to a SuperClass and then make all the other controllers extend this SuperClass. I then got to know that we can add it in the ActionController class itself. How can we do that? Is there a way to change the pre defin...
Hello,
To the rails experts out there I was wondering where/how you would execute the same code for every action in your web application? If you can point me to an article or provide a short code snippet I would greatly appreciate it.
Thanks in advance to anyone who can help.
...
Hi there,
I've got a sweeper that's supposed to expire a few action caches. Even though the debugger stops immediately before the call to expire_action, it's not actually expiring the action. Any idea what could be going on?
Here are the relevant sweeper and controller.
#company_sweeper.rb (in 'models' directory)
class CompanySweeper ...
I tried to write render in an action, but layout behavior is different, why?
def show
# assuming we have a partial in app/views/shared/_panel_show.html.erb
#render "shared/_panel_show" # have layout
#render "/shared/_panel_show" # without layout
#render "shared/panel_show" # Template is missing
#render :partial => "share...
I want to have some kind of single list that is initialized in a seperate module, then can be included in a controller and modified at the controller-class level, and accessed at the controller-instance level. I thought class variables would work here, but something strange is happening, they don't seem to be being initialized within my ...
Is it possible to configure Rails so caches created with caches_page survive a Capistrano deploy? Ie, can I configure the cache to be saved into a shared directory rather than in the public directory?
...