ruby-on-rails

How do you run rots in a Rails integration test?

How do you run rots in a Rails integration test? I can run rots from the command line, should I run the command from Ruby or is there a method I can call to get it to run? ...

How do I prevent a Builder template from escaping a URL in an attribute value?

I have a Rails Builder template: # in app/views/foos/index.xml.builder: xml.Module do |mod| ... mod.Content :type => 'url', :href => foos_url(:bar => 'baz', :yoo => 'hoo') end (It creates the XML for an OpenSocial Module file, but that's not important.) The problem is that the rendered XML lo...

script/generate on Windows: 'script' is not recognized as an internal or external command

Whenever I try to use the Rails script/generate or script/install command I get this kind of error: C:\workspace>script/generate bigcommand 'script' is not recognized as an internal or external command, operable program or batch file. Any idea why? ...

Good Git deployment using branches strategy with heroku?

What is a good deployment strategy to use with Git + Heroku (ruby on rails)? Currently the way I work with my origin git repository: All features (or 'stories') are first checked out as branches, then get merged with master and pushed to origin. Anything pushed to origin/master triggers a script that pulls the new rails code to the s...

How should I intergrate a facebook application into my current Rails app (what architecture)?

I want to create a very simple facebook application for my Rails app. At first since it is very simple, I created something in PHP, put it outside of the application space and set the callback URL to there. However, I would rather the facebook app live inside my Rails app (one reason is that so I can reuse views when necessary). Bec...

Ruby on Rails: Access information from other models?

Another newbie Ruby on Rails question: In my post view, I want to show the authors name. The post database table stores the authors id which is the same as the users id column in the users table. The user also has a username column in the user table. So having the users id, how do I get the users name? ...

Best way to add Disqus comments to a Rails application?

Is there anything better than the Disqus Ruby Gem? Perhaps something geared specifically towards Rails? (The Disqus gem might be the best option, I just haven't been able to find much color one way or the other). ...

Can Rails integration tests hit another server for OpenID auth?

Can Rails integration tests hit another server for OpenId authentication? When my Rails application, running on http://localhost:3000/, redirects to http://localhost:1123/server for OpenId authentication, Rails fake browser actually goes to http://localhost:3000/server. It seems like the fake browser used in the integration tests is ign...

Reading the first line of a file in Ruby

I want to read only the first line of a file using Ruby in the fastest, simplest, most idiomatic way possible. What's the best approach? (Specifically: I want to read the git commit UUID out of the REVISION file in my latest Capistrano-deployed Rails directory, and then output that to my tag. This will let me see at an http-glance what...

set rails root in environment

i'm deploying my app to a shared hosting environment, and apparently i need to set up the root path in my environment file. when i try to boot it up i get this error: ** Starting Rails with production environment... /home/donner/etc/rails_apps/donnerparty/config/../vendor/rails/railties/lib/initializer.rb:902:in `read': No such file or...

thread(?) database locking(?) in rails

Say I have this method: def create_registration_unless_over_limit if Registration.count < 50 Registration.create! else raise "too many registrations" end end How do I ensure that I never have >= 50 registrations considering that I have more than one rails process running? Theoretically, isn't it possible that two reques...

Rails: Internationalisation of Active Mailer

Hi there, I need to develop a Rails application that supports sending e-mails in more than one language. ActionMailer only supports a single template per e-mail 'view', and I don't want to make my own implementation that breaks with Active Mailer compatibility (departing from the notion that I would like to benefit from future vendor p...

How would you simulate Google Docs type functionality in a Rails app (without multiuser simultaneous edits)?

I know that there is an API for Google Data that lets you interact with Google Docs. But if you wanted to avoid Google Docs entirely and try to build similar functionality into a Rails app, are there any existig Ruby gems that could help you to achieve some of the key features: collaborative editing revision history On the other ha...

NoMethodError with collection_select

I'm building a form for a :has_many :through relationship: class Account < ActiveRecord::Base has_many :employments has_many :people, :through => :employments accepts_nested_attributes_for :employments end class Person < ActiveRecord::Base has_many :employments has_many :accounts, :through => :employments end class Employmen...

Problem with RESTful resource and ActiveScaffold

Hello everyone, I am trying to use a RESTful controller for user inside a namespace using AS and one outside for registration and so on. When i try to visit the namespaced url I get Unknown action. Once i replace active_scaffold :users with a def index; end i can the URL. My routes look like: map.register "register", :controller...

rails include with options

Is it possible to limit an AR :include to say only pull in one record... Item.find(:all, :include => [ :external_ratings, :photos => LIMIT 1 ]) I have a list of items and each item has between 5 and 15 photos. I want to load a photo id into memory, but i don't need all of them, I just want to preview the first one. Is there a ...

In rails, how to visit url with post method and submit some xml data?

For example, in rails, I want to vist the url "http://127.0.0.1:8080/solr/update" with the http method "post", and submit a xml data, how can I achieve that? ...

problem while trying to install plugin with Rails

Hi, I'm trying to install YouTube plugin as per instructions: ./script/plugin install git://github.com/vibha/youtube-model.git But I keep getting this error svn: '/Users/tammam56/rubydev/war/vendor/plugins' is not a working copy Plugin not found: ["git://github.com/vibha/youtube-model.git"] I made sure I have git which git /usr/l...

Validate hash of multiple select inputs in Rails

In a similar vein to a previous question of mine I need to validate a group of select inputs for order of voting preference. This time I've had to change it slightly. The options to a user would be something like: Choose in order of preference 1: [select with options] 2: [select with options] 3: [select with options] The hash that t...

popup WYSIWYG editor ROR

Hi I have to have a popup WYSIWYG editor into my ROR application. I want to develop the editor like www.wikispaces.com used. Here they used Jquery (if you want like that editor , you need to login ) . I want the same functionality . Can anyone please suggest how can i do this and please give me the reference site for the development JQue...