ruby-on-rails

adding some ajax to rails app using jquery

I have a simple drop down box on a page with the below code: <p> <%= f.label "Group" %><br /> <%= select("employee", "group_id", Group.all.collect {|p| [ p.name, p.id ] }, { :include_blank => true })%> </p> <div id="employees"> <!--this will be filled with ajax request--> </div> it shows Groups to the user. Wha...

RoR select_tag default value & options

hi, i am using select_tag in it how i can set the default value and, how can i keep the options open on page load thanks ...

how do i connect to server using ror

c:/ruby/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: no address a from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `open' from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect' from c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout' from c...

creating models with multiple references in rails

I have a model defined as class A < ActiveRecord::Base belongs_to :b belongs_to :c end How do I create a new instance of A associated with both b and c. I've got the ids for b and c. ...

In Ruby on Rails, if a note has many tags, how do I check if a note has any tags?

I tried note.tags.nil?, but it didn't work. How do I do this? Thanks for reading. ...

rails many to many self join

Hi, could some one point me to the right direction: I try to build a model for rails that build up the following: ClassA -id ClassA has a relation to many "ClassA" (so it is a reference to itself) I am searching for the migration and the model. I a not sure what the correct join table is (I think its a simple 2 columns table Cl...

Problems using Oracle with Rails

So, following a variety of tutorials, I installed the following gems on my windows box: "activerecord-oracle_enhanced-adapter" and "ruby-oci8" As well as modifying my database.yml to look like: oracle_development: adapter: oracle_enhanced database: 127.0.0.0:1521/sid username: uid password: pid Ruby OCI8 wouldn't compil...

Updating UI realtime in RoR after API Calls

Hi All- I am developing an app using the Amazon API found here, which unfortunately only allows a small amount of records to be returned at once, which causes a significant slowdown when loading any more than one call's worth of items. I'd like to make the returning of these records more seemless. I figure the way to do it, is to use ...

Charts library for Ruby

Hello there :) I am looking for a quite specific tool for generating charts, within Ruby on Rails application. I have done a research and couldn't find a solution that suits me. Maybe you've bumped upon it and could just point me to it with a link? :) My requirements for a solution are: it has to feature basic chart types like Pie, ...

Webrick Fails to Run as Daemon, no Error Message

Running Ubuntu Server 10.04 with Rails 2.3.4 and Webrick 1.3.1; our rails app runs fine when called via script/server -e production, but trying to test it as a daemon by calling it with the -d flag produces the following output: => Booting WEBrick => Rails 2.3.4 application starting on http://0.0.0.0:3000 Nothing is produced in the lo...

How do I silence the delayed_job output in test?

I am using delayed_job for background tasks such as system e-mails and different timed events. I use Delayed::Worker.new.work_off to work off the events in my RSpec tests, but then the test out put gets littered with sh*t like: [Worker(host:ch.local pid:24307)] RPM Monitoring DJ worker host:ch.local pid:24307 [Worker(host:ch.local pid...

Relationship like Twitter followers/followed in ActiveRecord

I'm trying to represent a relationship between users in my application where a user can have many followers and can follow other users. I would like to have something like user.followers() and user.followed_by() Could you please tell me in details how to represent this using ActiveRecord? Thanks. ...

Is it possible to add a function-based database-agnostic index via a Rails/ActiveRecord migration?

I have an ActiveRecord model like this: create_table "books" do |t| t.string "title" end class Book < ActiveRecord::Base default_scope :order => 'lower(title) DESC' end As you can see I want to sort by the lowercase form of the title attribute, but this imposes a performance hit at the database level. This hit can be remedied in ...

RoR: How to use *_path in a model ?

I need to generate a “report” in a model. This “report” has to include links. However, all the *_path functions seems to be unavailable in the model classes (a simple test show me that new_post_path raises an Exception in my models, but works fine in my controllers) Is there any way to use polymorphic_url or, at least, *_path methods in...

Rails - Devise and acts_as_audited

Hey, I want to use Devise and acts_as_audited together but when I try and link them using - class ApplicationController < ActionController::Base audit Candidate protected def current_user @user = User.find(user_session) end I get this error. stack level too deep Do I need to do it differently ? Thanks ...

Rails logging error: "Error during failsafe response: Shifting failed." ... is there an elegant solution to this?

I've configured my Rails 2.3.8 logger in the environment.rb to rotate daily: config.logger = Logger.new("#{RAILS_ROOT}/logs/#{RAILS_ENV}.log", 'daily') and every day in the morning I get the usual: Error during failsafe response: Shifting failed. Is there a decent/elegant/better solution to this? What I've done in the past is just...

Ruby on Rails: problem getting CKeditor to upload images.

When I pick a file and click "Send it to the Server" I get the error: ActionController::InvalidAuthenticityToken in MediasController#new_from_disk Parameters: {"upload"=>#<File:/var/folders/Fr/FrWbhcV1HdGpFgn7Lh7OhU+++TI/-Tmp-/RackMultipart20100802-4884-olu0e5-0>, "CKEditorFuncNum"=>"42", "langCode"=>"en", "CKEditor"=>"object_cont...

Rails Routing Conditional with multiple value options

I have a rails route that is based on two conditions, that the domain and subdomain are a specific value. The problem is that there are multiple possible values for subdomain to work, but I can't seem to be able to pass them as an array or hash. map.with_options(:conditions => {:domain => AppConfig['base_domain'], :subdomain => 'www'..'...

Using Cucumber/Capybara in Rails 3, how do I set a custom User-Agent string?

In my Rails 3 app, I have different layouts for iPhone vs desktop browsers. I'm trying to test the iPhone layout using Cucumber/Capybara. So far, all my attempts at setting an iPhone User-Agent string in the request's HTTP header have failed. I have followed the Testing custom headers and ssl with Cucumber and Capybara tutorial but it d...

How to (re)bind to submit button/form on .load(ed) form

During early in learning how to implement unobtrusive js (using Rails & jQuery) I've run into an issue of how to (re)bind a submit button/form after .load(ing) new content that includes a form. I've set up a 'create new item' form to show at the top of a lising of items (when the user clicks on a create button) sale_case/show/_requirme...