ruby-on-rails3

How to use Rails 3 scope to filter on habtm join table where the associated records don't exist?

I have an Author model which habtm :feeds. Using Rails 3 want to setup a scope that finds all authors that have no associated feeds. class Author < ActiveRecord::Base has_and_belongs_to_many :feeds scope :without_feed, joins(:feeds).where("authors_feeds.feed_id is null") end ...doesn't seem to work. It feels like a simple t...

Rails 3 XML Builder / Twilio API

This Twilio API Sample code isn't working in Rails 3: #voice_controller.rb def reminder @postto = BASE_URL + '/directions' respond_to do |format| format.xml { @postto } end end #reminder.xml.builder xml.instruct! xml.Response do xml.Gather(:action => @postto, :numDigits => 1) do xml.Say "Hello this is a cal...

Rails 3 - How do I build a database table with loads of data?

I'm incredibly new to Rails and programming in general. Built my first, fairly static, Rails app. I have 100's of products (specifically t-shirts) that all have associated colors (RGB values) and sizes that I need to display on several product pages. Rather than hand-coding this information, I assume I need to build a database for it. ...

Locale sensitive character classes in regexp with validations?

validates_format_of :first_name, :with => /\A\w+\Z/ The validation doesn't pass if there are non-english character in first name, like Mölläinen. Changing Rails locale doesn't help. So how do you do culture/locale sensitive validation then? If the locale is EN, then \w should map to [a-zA-Z0-9_], but if it's FI, then it should map to ...

RSpec-2 and Devise

Hi, i create a customized devise registration controller and i want to test it with rspec. I've tried it with a very simple test : it "creates a new parent" do Parent.should receive(:new) post :create end but i get this exception: Failures: 1) Parent::RegistrationsController POST create creates a new parent Failure/Error:...

Ruby 1.9.2, Rails 3 Console: Not enough memory??

I just upgraded to Rails 3, and in the last 24 hours I have started to see a new error message popping up in my console: Errno::ENOMEM: Not enough space - <STDOUT> from C:/Sanj/Ruby192/lib/ruby/1.9.1/irb.rb:311:in `write' from C:/Sanj/Ruby192/lib/ruby/1.9.1/irb.rb:311:in `printf' from C:/Sanj/Ruby192/lib/ruby/1.9.1/irb.rb:311:in `output...

Rails 3 - Referencing the URL to determine if a Nav Item is class="selected"

The app can have the following URLs: /projects/ /projects/3 /projects/3/photos /projects/3/photos/312 I'd like to know how in Rails 3 I can look at the current URL and know which of the lines above is currently active, so I can add a class="selected" Additional exmaple.. If the user's browser is on: /projects And the Nav loo...

Rails, Why does this helper not output HTML, but rather HTML in quotes?

Hello, I have the following helper in my application_helper.rb file: def topmenu pages = { "projects" => projects_path, "photos" => photos_path } pages.map do |key, value| classnames = %( class="current") if controller.controller_name == key "<li#{classnames}>#{link_to(key, value)}</li>" end ...

How can I make Rails 3 localize my date formats?

I am working on a Rails 3 project where there is place for date input within a form. The text field with the date uses a date picker so there is no concern about the date being entered in a wrong format, however the date is being displayed in the :db format (e.g. 2010-01-21). (Note: this is specifically in form fields - e.g. <%= f.text_...

MYSQL wrong time.now

Hi there, We got a Rails 3 Server based on Ruby 1.9.2 running on a MYSQL DB and Problems with the time.now and time.zone.now setting. For better explaination we assuse its 13:00 UTC right now. Ubuntu Systemtime is set to 15:00 UTC +02:00 (Thats CEST (Central European Summertime) and is correct for our Timezone). The Rails time (time....

scoped and find_within

Iam using geokit-rails (http://github.com/jlecour/geokit-rails branch gem). I like to build a scope like a = MyModel.scoped a = a.limit(10).scoped a = a.find_within(10,:origin => [mylat,mylng]).scoped a = a.where(:visible => true) a = a.paginate(:page => @params[:page], :per_page => 20) But this does't work - after find the query will...

responds_to_parent in rails 3

How I will use responds_to_parent plug in rails 3. I had used it in rails 2.3.5. At that time there was no errors. But when I shifted to rails 3 its showing the following error undefined local variable or method `erase_redirect_results'. How to solve this issue? Please help me ? ...

Are there any Rails plugins that allow for Excel-like functionality in the views?

I am looking for a way to allow web users to view tabular information in a view, and interact with the data in a similar way. In other words: Tab through cells Highlight multiple cells Fill multiple cells simultaneously Does such a plugin exist? I have not been able to locate one via search engines. ...

rails caching problem with css

Hi, I have two different css files... style.css and style_main.css both are used separately in different layouts for the same application. In development mode everything works fine, but when in production mode, caching happens and both css files are loaded as all.css?xxxxxxx but unfortunately all.css is made from style.css and does not...

How can I remove a gem from my Rails 3 project without getting this really strange Bundle error?

The error is: You have modified your Gemfile in development but did not check the resulting snapshot (Gemfile.lock) into version control WHAT VERSION CONTROL? Why/how does Bundle know anything about version control? I just removed a line from my Gemfile. Am I not supposed to do that? ...

Rails Nested Attributes Mass Assignment Error

I have a user model where I cannot create a client due to it being unwritable in mass assignment. How do I make it so that I can create a client model? Code and error are found here: http://pastie.org/1206482 ...

Rails newbie: How to add routes to a rails 3 engine?

Hi folks, I'm trying to write my first rails 3 gem - everything works well, except for routes - I can't seem to get them working. It's possible this is a very simple error - as mentioned, it's my first experience with engines. The gem itself is very, very basic - literally just one scaffold My gem's config/routes file: class ActionCon...

how to modify complex sql query w/ join into rails 3

I'm working on a car pooling application where users can add lifts and are able to select multiple stops for each lift ( A to B via c, d, e). Now when a user searches the database for a lift the results should also include lifts like 'A to d', 'c to B' or 'c to e' and so on. I got this working with Rails 2.3.5 using the below code but st...

Rails 3 and 2.3.8 fail to save a model called "Update"

I have this: class Update < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :update end Update.first gives: #<Update id: 1, body: "update 1", ...> Comment.first gives: #<Comment id: 1, update_id: 1, body: "comment 1", ...> When doing this: Comment.first.update_attribute(:body,"This ...

Rails 3 routing failures

I'm having a couple issues with Rails 3 routing, and I just can't fathom why things aren't working. For instance, I have a functional test that includes: assert_routing("/store/users/[email protected]/license/ch7bHtrx", {:controller => 'store/users', :action => 'license', :email => '[email protected]', :id => 'ch7bHtrx' }) which p...