ruby-on-rails

render a partial from jquery and haml

Hi guys, The functionality I plan on doing is to insert some form elements depending on a number chosen from a select tag. I have a select tag called for number_of_passengers, and i plan to dynamically append new passenger fields for the number chosen. Say I select 2 from number_of_passengers, then 2 forms should appear in a fieldset. ...

Create A User (Owner) and then Create A Team using Devise

Hello I have been trying for several days using nested attributes, etc. Basically, I want a User to SIGN UP. Once the User is 'Signed Up' I want them to be redirected to 'Create Your Team' page. Once they created their Team, then they are redirected to their Team Dashboard. But what if a User didn't create the Team right away? I would ...

Changing which Rails Validations run depending on current user in deeply nested form.

I'm working with a nested form that encompasses a total of 7 models, each with different validations. When simply editing the form, the validations run and display fine, and data is saved properly. However, I need to have different validations run depending on who is submitting the form (ie, admins can skip some otherwise required fields...

Rails migrations - look for changes in old migrations?

If I have two migrations, mig1 and mig2, I run rake db:migrate, then I go back to mig1 and change the default value of a column, will this change be reflected when I run rake db:migrate again? Or do I have to make a new migration just for that column to make the change? ...

Any popular Rails tricks for keeping a nav's css selected when flipping through partials?

I have an admin with a nav. The nav toggles between different partials. The nav has several li's, and when one of them is selected, it gets the .selected class that makes it highlighed. Is there anyway to toggle this from the controller? Or any other place that's popular among Rubyists? ...

Ruby on Rails: How to populate an array using a form?

[noob disclaimer] So I'm beginning with rails and I'm trying to have a form that adds toppings to a food order. How can I make a form that for each checkbox 'ticked' the submission will add that topping to the array of ordered toppings to that food? ...

Benchmarking rails ActiveRecord Queries

I'm looking to benchmark a couple of my ActiveRecord requests in my app. What's the simplest way in the console to benchmark something like User.find_by_name("Joe").id versus User.find(:first, :select => :id, :conditions => ["name = ?","Joe"]).id Thanks ...

Something like sharepoint but built in ruby on rails?

Are there any gems, plugins, frameworks etc that give sharepoint like functionality (list and file management & versioning) but are based on ruby on rails? ...

searching a model in rails for 2 values?

Hi I wrote this retrieval statement to check if an appointment being saved or created dosent conflict with one thats already saved. but its not working, can someone please point me to where I'm going wrong? @new_appointment = :appointment #which is the params of appointment being sent back from submit. @appointments = Appointment.all(...

SQLite3/Ruby statement question

Hello, I am trying to import a file as a table in SQLite 3 using a Ruby script. I need to assign a tab separator, and I used the following code: db = SQLite3::Database.new("meshdb2.db") db.execute("CREATE TABLE IF NOT EXISTS pubmed(id integer primary key,prideID INT NOT NULL,pubmedID VARCHAR(10) NOT NULL) db.prepare(".separator '\t'") ...

Sort association models in Rails 3?

Menu has_many :dishes. I want to sort the dishes by Dish.number. Currently in my view it looks like: <table class="menu"> <% @menu.dishes.each do |dish| %> <div class="dish"> <tr> <td> <div class="dish_div dish_name"> <% if @menu.name != 'Övrigt' && @menu.name != 'Box to go' %> <...

How do I profile my Ruby test suite in aggregate?

The usual sob story: my tests are running slowly. My first thought was to profile the whole test suite to look for obvious wins (stubbing out network access or caches), so I added a ruby-prof task: RubyProf::ProfileTask.new(:units) do |t| t.test_files = FileList[RAILS_ROOT + '/test/unit/**/*_test.rb'] t.output_dir = Dir.tmpdir t....

identifying conflicting appointments in rails works for update but not create?

Hi I wrote this conflict method to check if an appointment being saved or created dosent conflict with one thats already saved for a particular trainer. this method is called first thing after a person attempts to create or update existing appointments in the def create and def update. it works when updating the appointment but d...

Why is stylesheets and scripts separate from app in rails directory structure

Hey all, I never understood why the stylesheets and scripts are outside the /app folder in ruby on rails. Is there benefits of housing them in the /public folder away from the /app? Thank! Matt ...

Deep eager load on rails

In this thread know how to make a eager load in rails, but how to do this nested? I.e: # get category, random product and random photo @category = Category.find(params[:id], :include => random_product, :include => random_photo) I don't know if I explain... Thanks in advance. ...

Getting a list of all packages from shipping carriers.

I've been looking at the APIs for UPS, FedEx, USPS, etc, and I can't seem to find any method of pulling all tracking info for a given user. I only see methods that pull info via a tracking number. Has anyone been able to find a way to get at this data? Seems silly to me that these huge carriers wouldn't supply this info in an easy method...

Prevent Rails 2 from caching of Lib/ Classes

Does anyone know how to instruct rails to NOT cache classes that are included within the lib folder? ...

How can I colorize logger output in a rails 3 console

How can I colorize and possibly bold the output from Rails.logger in my rails3 application? ...

Where is the new_post_path, edit_post_path, posts_path ... lies in the source? I need to override them

Where is the new_post_path, edit_post_path, posts_path ... lies in the source? I need to override them. my env: ruby-1.9.2-preview rails-3.0.0.beta3 ...

Monkey Patching in Rails 3

What is the preferred way to Monkey Patch in Rails 3? I just want to add a method to the String class. I'm more looking at where to place the file. ...