ruby-on-rails

Rails: Fields_for without a scope?

Is there a way to use fields_for with in a form without having a scope? For example: <% fields_for "user[]" do |x| <%= x.text_field :name %> <% end %> Without the user model being loaded in memory? I got it working using territory[user][][name], but I would like to keep it in ERB. ...

What are your Rails bookmarks to help you solve problems and learn?

When you're solving a problem in Rails, what websites do you turn to as resources? (... other than StackOverflow!) I'm not looking for links to tools such as IDEs, but rather information resources. One url per answer please to help voting. ...

Big Web 2.0 sites written in Python?

Hulu, Twitter, Techcrunch, etc are written in Ruby. Yahoo, Facebook, and tons of big social networks are written in PHP. But what are some big top-name enterprise sites written in Python? I am going to spend my time investing in either Python (w/ Django) or Ruby (w/ Rails) to create a data-intensive web application that has a personali...

Two forms having the same action

Hello, I have two forms in my rails app. They both exist in separate tabs and I when I submit one form I want the data in the other form to be saved as well. How should I do that? Or Is there a better way of doing this instead of using two separate forms? Is there a better way to spread a long form into multiple tabs and when I press su...

How do you mix Phusion Passenger in a mod_perl virtual host?

I have a VirtualHost which sets the handler for Location / to a PerlModule to deploy a catalyst application. I want to convert the catalyst application to rails, but gradually. The front end is all javascript using the ExtJS Framework, and the backend only serves JSON. This will allow for a gradual transition as long as the JSON is i...

Nesting content tags in rails

Hey. I've got some code from Agile Web Development that wraps some HTML around a method call as so: # from tagged_builder.rb, included as a FormBuilder helper def self.create_tagged_field(method_name) define_method(method_name) do |label, *args| @template.content_tag("p", @template.content_tag("label" , ...

Java Servlet Filter Equivalent in Ruby [on Rails] and PHP ?

Not sure if the terminology is correct, but are there rough equivalents to Java Servlet Filters in Ruby and PHP ? Are they actual concrete classes ? I assume there is also a number of common web app libraries/frameworks in Python. Is there an equivalent there ? Thanks. === ADDENDUM === On the good advice of Kevin Davis, I just want t...

Require path problem

Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile in the root path of every rails project. I guess this line is used to require vendor/rails/railties/lib/tasks/rails.rb to get all rake tasks loaded: $VERBOSE = nil # Load Rails rakefile extensions Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| l...

Scaffolding ActiveRecord: two columns of the same data type

Another basic Rails question: I have a database table that needs to contain references to exactly two different records of a specific data type. Hypothetical example: I'm making a video game database. I have a table for "Companies." I want to have exactly one developer and exactly one publisher for each "Videogame" entry. I know that ...

Does Rails have a built-in authentication system?

I have implemented authentication systems for webapps several times over the years, but before I do it once more, I thought I'd ask if there's a canned solution I should know about. Last time I checked, there was no built-in Rails authentication system and the standard solution was the restful-authentication plugin. Is that still the ca...

"No such file to load" error when running Rspec

Mac OS 10.4 rspec (1.1.11, 1.1.4, 1.1.3, 0.5.15) rspec-rails (1.1.11) rspec_generator (0.5.15) rails 2.2.2 ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0] Created a new project... $ rails myproject Installed rspec into the project... $ script/generate rspec Generated a resource... $ script/generate rspec_scaffold myre...

Is it better to dive into Rails or Django going into the future?

I've been a dev using rails since it's initial release and have recently lost touch with it because I've done a lot of work with Django due to my recent fondness of python. I do like Ruby as well and was asked by a friend recently if he should approach Rails or Django. Given that Rails is merging with merb and has a huge user-base versus...

MySQL partitioning with ActiveRecord

I want to take advantage of the new partitioning in MySQL 5.1 but using a standard ActiveRecord model. The problem I have encountered is that to use the partitioning the primary key on the table must include the columns used in the partitioning function. (http://dev.mysql.com/doc/refman/5.1/en/partitioning-limitations-partitioning-keys...

How to get last N records with activerecord

With :limit in query I will get first N records. What is the easiest way to get last N records? ...

Best way to collect Rails application usage statistics

I have a Rails application where users can set up their domains and publish content onto them. I need to collect public traffic statistics such as pageview count etc. One good example of this feature is flickr usage statistics i can see as a customer. The question is what is the best way to collect usage information. Should it be done b...

Primary servers in capistrano

I have a task in capistrano wherein I want just a single line to run only if the server is a marked as primary. Is there a variable or method that I can reference inside a task? 'primary?' or 'primary' doesn't seem to work. I've also tried something akin to the following: after "deploy", "task1" after "deploy", "task2" after "deploy"...

how to load a div into html using jquery

I'm trying to load a div into a page based on a change in the drop down. I either want to show a div which has state/zip or province/postal_code, (each is a file) but I am getting a "406 Not Acceptable [http://localhost/profiles/residency]" Here is my JQuery code: $(function(){ $("#profile_country").change(onSelectChange); }); fun...

Best way to test RJS in RSpec Controller specs?

What is the best way to ensure that the proper RJS is being generated in a Controller action? For example, I want to ensure that a div is highlighted as such: def new render :update do |page| page.visual_effect :highlight, :some_div end end Rant: This is quickly becoming one of the reasons I grow tired of RSpec after using it...

How to "sell" ruby on rails to a client

Tomorrow, I will meet a client that is not working in technology but might ask if RubyOnRails is the right choice for his site. He might think that there's not enough RoR programmers and that he will be "hostage" of the language. I have good reasons to use RoR and the client has good reasons to like it (it costs less!). Do you have "of...

Why can't I install the sqlite gem?

I'm try to install the sqlite gem on a Fedora 9 Linux box with ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here's the command I'm running and its results: sudo gem install sqlite3-ruby Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. ...