Displaying 20 results from an estimated 30000 matches similar to: "Recognizing routes?"
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all
actions...and their views?
eg.
class ApplicationController < ActionController::Base
@current_user = User.find(session[:user_id])
end
and everywhere I can call @current_user.id and I can get that object? Even
down in the views?
I could not get this to work...
Thanks in advance,
Jeff
-------------- next part
2006 Jun 06
1
Default value plugin
I''m releasing a very small plugin that allows you to specify default
values for fields in models. Ordinarily, you might do this in your
schema, I guess, but then it''s awkward if you need that on a
serialized field or need your default values calculated somehow.
So you can do something like this: (repeated from an earlier post and
the README)
class Mixture <
2006 Aug 14
1
Rest, routes, path_prefix and default params
I am trying to use routes with default params to have routes
''/mycompany/departments''
and
''/companies/1/departments''
mean the same thing (both restful routes).
When I set up the files as below, I get an error of
''Couldn''t find Company without an ID''
and my log file shows the following ..
Processing DepartmentsController#index (for
2006 Apr 23
3
ANN: Polygons library + sweet demo
Hello!
I''m releasing an extraction from an application I''m currently working
on. It''s a small library for dealing with points and polygons, called
Polygons. It really just implements some textbook algorithms w/
Prototype-style JavaScript classes. Check it out here:
http://polygons.mdaines.com/
The demo on that page (Firefox/Safari only right now) uses the
2011 Jun 21
0
Status of Rails.application.routes.recognize_path()
This might be more a question for the guys in the "Ruby on Rails: Core"
group, but I''ll try it out here first...
So, while writing a gem (engine) for rails, I found that I needed to have my
app (in a pre-filter) directly query the router. In the "old" days, this was
done using ActionController::Routing::Routes.recognize_path(). My 2nd
edition of "Agile Web
2009 Mar 06
2
Routes.recognize_path on more complicated Routes
For a permissions system i''m writing i''m extending the standard link_to
helpers to check if a user has a permission to perform that action
before displaying a link to clean-up my code so i don''t have to put if
checks all over them.
I''m trying to use..
ActionController::Routing::Routes.recognize_path(url, :method => method)
to get the action and controller
2007 Dec 28
1
Rake routes & console showing one thing, app doing another
OK, I have a routing problem, that seems to be working in the console,
and with rake routes but not in the app.
I have people that have nested tasks, like so:
-------------------------------
# routes.rb
map.resources :people do |person|
person.resources :phone_notes
person.resources :documents
person.resources :tasks, :member => {:complete => :put}
end
map.resources :tasks, :member
2011 Jun 22
3
Status of Rails.application.routes.recognize_path()
Sorry if this question isn''t really "Ruby on Rails: Core" material. I feel
it is, at least kind-of (also, I first tried asking in "Ruby on Rails: Talk"
to no avail.).
So, while writing a gem (engine) for rails, I found that I needed to have my
app (in a pre-filter) directly query the router. In the "old" days, this was
done using
2006 May 18
2
Help with Routes
I love the routes feature for RoR...until now. I''m trying to write tests
to make sure my urls are correctly mapping to the routes I expect them
to map to. This is driving me nuts because I simply can''t get any of my
tests to pass. I have thus concluded that routes must work differently
than I thought. I will try to explain my understanding of how routes
work. Via this
2007 Mar 09
1
Specifying RESTful Routes
What would be the proper way to specify this route?
ActionController::Routing::Routes.draw do |map|
map.resource :recipes
end
Would the specification go into recipes_controller_spec? Also, what
methods are available for testing RESTful routes (i.e. GET, POST, PUT,
DELETE)?
2008 Jan 25
2
Routing optimization, named routes and default url options
I came across this when switching from rails 1.2.6 to 2.0.2, there is
a change in the way routes are generated between these to version due
to the routing optimization in rails 2.0.2.
In version 1.2.6 it was possible to overwrite the default_url_options
method in ActionController::Base to define parameters attached to each
generated url.
Due to the routing optimization in rails 2.0.2 this is not
2006 Jul 11
0
assert_redirected_to not recognizing routes
I''m getting a weird error in a call to assert_redirected_to in one of
my functional tests. Here is the test:
def test_signin
admin = users(:adminuser)
post :signin, {:login => admin.email, :realpass => @password}
assert_redirected_to :action => ''list'' # failure happens on this line
assert_equal admin.id, session[:user].id
end
The error
2005 Dec 15
0
Creating and managing Rails routes on the fly
Here is what I''d like to be able to do:
I want to be able administer routes using a rails application. So an
interface
would list routes and give users the ability to manage these on the fly:
class RoutesController < ApplicationController
# very simple example
def add
...
Routes.connect ''customurl'', :controller => "customcontroller",
2006 Jun 21
1
Adding routes via plugins
Hi,
I''m attempting to add a route via a plugin. I attempted to add the following to my init.rb:
myroute = ActionController::Routing::Routes.connect "boo2", :controller=>''plugin'', :action=>''index''
puts "path=#{myroute.path}"
myroute.options.keys.each do |k|
puts "#{k}=#{myroute.options[k]}"
end
The newly
2006 Sep 26
0
some help with functional testing of nested routes
I have the following functional test in test/functional for testing my
products_controller:
require File.dirname(__FILE__) + ''/../test_helper''
require ''products_controller''
# Re-raise errors caught by the controller.
class ProductsController
def rescue_action(e)
raise e
end
end
class ProductsControllerTest < Test::Unit::TestCase
fixtures
2006 Aug 09
0
recent changes in routes
I''m writing a plugin that automatically creates a named route buy
hijacking RouteSet''s draw method. This no longer seems to work in
edge rails. Anyone know what changes in routes effected this and what
the preferred way would be now to automatically include route?
Here''s the code that used to work:
class ActionController::Routing::RouteSet
alias_method
2007 Oct 26
0
Composite Keys on RESTful Routes
I am building an app with existing controllers/actions, using
traditional rails routes. I recently started moving over to RESTful
routes and have hit a snag. Now I am reconsidering my whole effort
and may go back to the original, more flexible, map.connect method.
My problem is, one of the resources has composite keys. The keys are
both strings as well, and can include dots. Here''s
2006 Feb 08
2
Adding routes via a plugin...
I have a plugin that I am working on that will as part of its distribution
contain a controller. I would like to be able to add a route for it in the
plugin''s init.rb so that when the plugin is loaded, the route will
automatically be registered without having to force the user to edit
routes.rb or even make a rake task to do it for them.
I saw the following code in one of the SVN
2006 Feb 13
1
dynamically generating a controller and appropriate routing
I''m working on a library similar to acts_as_taggable. I''d like it to be a
simple, one file drop-in: i.e., put my_library.rb into RAILSROOT/lib/ and
have everything work. However, the library requires a controller to render
some stuff, so I need to be able to create the controller class, set the
routing, and extend the controller at run-time from within my_library.rb.
I have code
2007 Jan 19
6
Problem w/ routes.rb
I am trying to develop a new webapp using Rails 1.2.1. I am installing
it onto a production web server running Apache w/ fastcgi. The server
already has some older webapps running on it using an older version of
Rails. The apps are not installed in the document root; they each have
their own subdirectory which is a symlink for the apache document root
to the "public" directory of each