I have a standard rails observer configured:
class TipObserver < ActionController::Caching::Sweeper
observe Tip
def after_save(tip)
profile_link = link_to tip.profile.name, profile_path(tip.profile)
Profile.followers(tip.quality).each{|profile|
message = Message.new
message.sender = Profile.first
message.re...
Hi,
I have the followed Rails 3 routes:
Hello::Application.routes.draw do
resources :blogs do
resources :articles do
resources :comments
end
end
end
By raking them, we can find:
GET /blogs/:blog_id/articles/:article_id/comments(.:format) {:action=>"index", :controller=>"comment...
My ViewModel class has a property that contains a ShareClass object. ShareClass has a property called Id.
I'm currently passing the ShareClass id into the action method as follows:
public ActionResult ListedFactsheet(int shareClassId)
{
}
I'd like to be able to use the ShareClassViewModel though instead of passing in an int, as ...
I want the url of a user post to be like this:
example.com/users/username/post-name
How should I set this up?
Currently, the post model contains:
def to_param
name.parameterize
end
(to hyphenate the post name accordingly)
routes.rb contains:
map.resources :users
map.resources :posts
Preferably, I would like to say ...
Once the app is deployed to the web server, I type in an invalid route the mvc app just hangs and then displays a blank page.
On my local IIS, if I type an invalid route I get the exception: "System.Web.HttpException: The incoming request does not match any route.". I want the exception not the blank page.
Any ideas?
...
My routes work fine apart from when I am at an action that requires a parameter. For example, these work ok:
/news
/news/admin
/news/admin/add
But this doesn't:
/news/admin/edit/1
But only routes using the 'default' route render incorrectly (they render as ../../module/controller), all other routes render correctly (/module/conntro...
This is likely something easy to accomplish, but I'm having difficulty even articulating clearly, leading me to get all sorts of semi-germaine, but not quite what I'm after posts on SO when searching.
I have a resource, we'll just use User as a simple to discuss use case. I desire SEO friendly URLs, so instead of ~/users/:id, we have ~...
I have a comment form (in comments/_form.html.erb) that I use in my other controllers (posts and tags).
<% form_for([@post, Comment.new], :html => { :multipart => true }) do |f| %>
<%= f.text_field :commenter %>
<%= f.text_field :email %>
<%= f.text_area :body %>
<%= f.submit 'submit' %>
<% end %>
In my Comment mo...
I have a model called NoteCategory, which is functioning as a join table between Notes and Categories.
Up till this point, I have used scaffolding to do everything in RoR. I'm trying to learn how to do some stuff more manually.
I want to have a link that will appear next to each category on a note, that will remove the category from t...
I already have a php file that takes the contents of an html form that I've now converted to Rails. I don't want to rewrite the php in rails but I'm having issues posting to it. I put the php file in the public directory and can access it if I type the address directly but when I submit a form with it as the action rails serves a 404 not...
So Authlogic ships with some pretty confusingly (for an end user) named routes. For example, instead of /login/new, you get /user_session/new, and so on. Then, when a user can't login, the error message appears as "This user session could not be saved."
It's a small thing, but that's just kind of... ugly, to me. What's a graceful way to...
i would like an index action to be able to take get and post methods, is this possible and if so how?
how do you write the route if in this case
map.resources :content, :only => [ :index ]
Many thanks
...
map.resource :basket, :collection => { :checkout => :post }
The above does not work for a resource, as you would expect since basket is a resource (ie. singular) not resources, so there is no concept of a collection, everything should be scoped to the current_user. In this case User has_one Basket.
However I would like to specify a ...
Subdomain behavior is not working as I expect in my Pylons project. Can someone provide some insight? I was using a named route and received back a URL that did not contain my current subdomain:
I have the following rule defined on my mapper:
map.sub_domains = True
...
map.connect('openid_verify', '/verify', controller='oid...
Hello,
When a page is served, i.e., http://some.tld/FAQ.aspx, dynamic compression works just fine; The aspx extension is registered as a file type to compress.
But when using routes.MapPageRoute to rewrite the url as some.tld/FAQ IIS will not compress this page. There's no extension to register here.
Does anyone know how to get IIS to...
Hello all,
I installed the following gems in addition to rails 2.3.5:
i18n (0.4.1)
i18n_routing (0.3.7)
In environment.rb I added
require i18n_routing
Inserted the following lines in routes.rb:
map.localized(I18n.available_locales, :verbose => true) do
map.resources :users
map.resource :contact
end
but when I restart the se...
All of the pages and resources that php will give through readfile() exist in a database table entities. The entities table includes the uri alias for the object, what type of object it is so it can properly route it. Should I just include it in application/config/routes.php, should I write some helper functions and include them in the...
Hi,
We have a "legacy" flash application relying on PHP to deliver it's data, but the server side is now being upgraded to Rails 3.
For various reasons we don't want to change the flash, so we need to be able to route http requests like this: http://www.example.com/somefile.php?param=123&otherone=123457 to RESTful rails routes.
I...
Hi -
I have a 1.2 app that I'm updating to 1.3. I need to send all top level requests like /foo to a controller action (/sites/view/$1) if they are not a valid controller. So in my 1.2 app I had a route like this (incredibly ugly I know):
Router::connect('(?!admin|billings|carriers|clips|cliptypes|contacts|domains|faqs|leadcomments|...
I'm using Rails script/console to learn REST routes. It is very handful!
In order to do that I need to paste these two lines every time I run console:
include ActionController::UrlWriter
default_url_options[:host] = 'whatever'
If there is any way to make a script which will add this automatically every time I run console?
...