ruby-on-rails

In Ruby on Rails, why http://localhost:3000/foobars/alt/1.xml not work?

In Ruby on Rails, http://localhost:3000/foobars/alt/1 works but http://localhost:3000/foobars/alt/1.xml doesn't work. config/route.rb is map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' so supposedly it supports an id.format in the URL? ...

In Ruby on Rails, the :id is only optional in routes.rb? How to tell optional vs not optional?

In routes.rb map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' but then http://localhost:3000/foobars/alt will work too. The params are: {"action"=>"alt", "controller"=>"foobars"} so looks like :id is optional here. How can you tell it is optional vs not optional? Can you make it so that...

How do I access my web application from a non-local machine?

hi, I have a Ruby on Rails application that I'm developing on my computer, which runs Ubuntu 10.04 LTS. I'd like to be able to access it from a remote computer for testing purposes. I've no idea how to proceed. Do I need to set up port forwarding? Virtual hosts? Can anyone point me to an article/tutorial/whatever that has information ab...

STI and subclasses

Hi All, I want to know, what is a rails way of converting a subclass record to another subclass record, just changing type isn't working and also superclass to subclass and vice versa. Thanks in advance Markiv ...

Use super with before_validation.

I have this code in my every model. Class people def before_validation @attributes.each do |key,value| self[key] = nil if value.blank? end end end Now i want to put my loop in separate module. Like Module test def before_validation @attributes.each do |key,value| self[key] = nil if value.blank? ...

Rails layouts per action?

I use a different layout for some actions (mostly for the new action in most of the controllers). I am wondering what the best way to specify the layout would be? (Consider like I am using 3 or more different layouts in the same controller) I don't like using render :layout => 'name' that much. I did like doing layout 'name',...

Does ruby on rails have issues with regards to max # of threads the server and serve?

Does ruby on rails have issues with regards to max # of threads the server and serve? i.e. you have to run multiple instances of the server if you reach high load? ...

Does Ruby-on-rails require sticky sessions? Can the ORM handle multiple db's or does it have a session like hibernate?

Does Ruby-on-rails require sticky sessions? Are they any scenerios where a user HAS to be using the same server ? Can the ORM handle multiple db's or does it have a session like hibernate? Meaning, can I have a single installation of the web application, yet have all my clients run on their own instance of mysql or their own seperate ...

Two Different Types of Associatons on the Same Two Tables in Rails

I have two models, users and themes, that I'm currently joining in a HABTM association in a themes_users table. Basically, after a user creates a new theme, it becomes available to other users to select for their own use. However, only the original creator of the theme should have the ability to edit it. So, I need to have some other ki...

Extracting a Rails application into a plugin or engine

I have a Rails 2.3 application which I would like to extract into a plugin, or engine. The application has user authentication, and basic cms capabilities supported by ancestry plugin. I want to extract the logic for the application into a plugin/engine so that I can use this code for future projects, with a different "skin" or "theme" ...

nested form & habtm

so i am trying to save to a join table in a habtm relationship, but i am having problems. from my view, i pass in a group id with: = link_to "Create New User", new_user_url(:group => 1) User model (user.rb) class User < ActiveRecord::Base has_and_belongs_to_many :user_groups accepts_nested_attributes_for :user_groups end ...

facebook_session.user.email = nil?

I'm using authlogic_facebook_connect plugin on my RoR app. Looking to get extended permission from the user to acquire their facebook email address so that I can use this email to store in the database as their "myapp.com" registration email. This way a user can come to the site and click on the facebook connect button and be automatic...

Specifying Entire Path As Optional Rails 3.0.0

I want to create a Rails 3 route with entirely optional parameters. The example broken route is: match '(/name/:name)(/height/:height)(/weight/:weight)' => 'people#index' Which results in 'rake:routes' yielding: /(/name/:name)(/height/:height)(/weight/:weight) And thus adding an initial slash to all links: <a href="//name/kevi...

Rails belongs_to issue in the views

Hi, Im having problems with an association in rails: Currently I have Post and User models, and the relationship is set this way: class User < ActiveRecord::Base attr_accessible :username, :name, :lastname has_many :posts end class Post < ActiveRecord::Base attr_accessible :title, :body belongs_to :user end However, in my ...

Rails: redirect_to :controller=>'tips', :action => 'show', :id => @tip.permalink

hi, I tried to redirect rails to show action by passing controller, action, and params. However, rails ignores the name of action totally! what I got is http://mysite/controllername/paramId so i have error message.... here is the action code I used: def update @tip = current_user.tips.find(params[:id]) @tip.attributes = pa...

How can I get ambethia's captcha plugin to work in rails 3?

I have installed ambethia's captcha plugin as a plugin in my rails 3 app. When I put the <%= recaptcha_tags %> in my view, it prints this on the page: <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=my_key&amp;error=expression"&gt;&lt;/script&gt; <noscript> <iframe src="http://api.recaptcha.net/noscript?k=my_ot...

The command redirect_to "http://google.com" doesn't appear to be working!

So I have the final line in my controller: redirect_to "http://google.com" And the prod log has: Redirected to http://google.com Completed in 8ms (DB: 4) | 302 Found [http://www.exmaple.com/728zz5d/delete_stuff] And the web page still had the original info - I'm not sent to google??? What am I not understanding? ...

RSS Feed to Twitpic

I'm curious to what is required to translate an xml feed of images to TwitPic. Is it possible? Can it be done with Ruby on Rails? Is it against TwitPic's Terms of Service? What is the best method of getting pictures on twitter automatically? (Established services like TwitPic, yFrog, etc are preferred because most twitter apps display th...

Labeled fixtures for associations in Rails 3 broken

After upgrading to Rails 3, fixtures that refer to other labelled fixtures (for relationships) stop working. Instead of finding the actual fixture with that name, the fixture label is interpreted as a string. Example: # Dog.yml sparky: name: Sparky owner: john # Person.yml john: name: John Where Dog "belongs to" person. The...

What happens if two people submit edits at once

Hi there, This might be a stupid questions but I wanted to know what happens if two users edit some data at once and then both click submit at the same time, I assumed Rails handled requests one after the other and so someone would get an error message but is this correct? Thanks Once one person has edited data I dont want it to be ac...