ruby-on-rails

Vital Ruby concepts to learn before I jump into Rails?

Disclaimer - Ruby is the first language I've ever learnt. I don't have any CS background. I've worked through "Learn to Program" by Chris Pine which has been enjoyable and I now understand the basics pretty well. The next recommended book would be "Programming Ruby 1.9" (the next PickAxe). From what I've read it's just a massive referen...

What CI server and Configuration Management tools I should use

Hi ! What CI server and Configuration Management tools I should use together for a truly development and deploy maintenance. There isn't the de facto rails sustainable environment, is there? Some assumptions: • code control version ok - git (de facto tool) • test framework ok - whatever (rspec is my choice) • code coverage and anal...

Rails - Why can't I use a method I created in a module in my tests?

I created a module in lib directory and I can freely call the various methods it contains throughout my Rails app (after adding include ModuleName) with no problems. However when it comes to tests, they complain no such methods exist. I tried including the module into my test helper with no luck. Can anyone help. 4) Error: test_valid_s...

Rails pass ID from auto_complete field to observe_field

<p>Song Name:<%= text_field :songlists, :song_name, :id => "songlists_" + section.id.to_s + "_song_name" %></p> <%= auto_complete_field "songlists_" + section.id.to_s + "_song_name", :method => :get, :with => "'search=' + element.value", :url => formatted_songlists_path(:js) %> <p>Artist:<%= text_field :songlists, :artist, :id => "s...

Rails and JSON: a beginner's question

I'm looking for a simple way to parse JSON, extract a value and write it into a db in Rails. Explicitly what I'm looking for is a way to extract a shortUrl from the JSON returned from the bit.ly API: { "errorCode": 0, "errorMessage": "", "results": { "http://www.foo.com": { "hash": "e5TEd", "shortKeywordUrl": "", "shortUrl": "http://b...

What is the best strategy to combine IntrAnet and Web-exposed website?

I was wondering if somebody has some insight on this issue. A little background: We've been using Rails to migrate from an old dBase and Visual Basic based system to build internal company IntrAnet that does things like label printing, invetory control, shipping, etc - basically an ERP The Dilemma Right now we need to replace an old ...

rails - how to override default views

by default, when i ask rails controller to do messages/index, he does def index respond_to{|fmt| fmt.html} end and shows app/views/messages/index.html.erb there is a customer which wants his instance of the platform to display views differently (and changes cannot be done with css only). solution i think of would be create direct...

Gems not found with Passenger in conservative spawn mode on Mac OS X

We are using Passenger locally on Mac OS X for development. I switched to conservative spawn mode to try to debug a problem with the MongoDB ruby driver. However, after I did this, Passenger can no longer find my gems. I get the application failed to start page with this message: Missing these required gems: aws-s3 >= 0.6.2 ruby-u...

what does 'invalid gem format' mean?

Does this mean I've hosed my ruby/gem/rails environment somehow? I've been using InstantRails2-0 happily for awhile now, but recently decided to upgrade rails. It has been a major pain so far. First I had issues getting the latest gem version, rubygems-update couldn't get the latest. I was finally able to get the latest gem version by ma...

Parse Rails console output into Excel

Perhaps an oddball question. Doing a Model.all or the like gets me a somewhat pretty output of the array, [#<Model id:5, name:"Blahblah">,#<Model id:5, name:"Etc">]. Is there an easy way to convert this into a CSV/Excel format with the attributes as columns? ...

accessing data from the model using script/console (Ruby on Rails)

I'm looking to write a Ruby script which I can load into the Rails Console which will access data from the models I have created. I created a model called student using the following command and populated it with data: script/generate scaffold student given_name:string middle_name:string family_name:string date_of_birth:date grade_point...

Mysql query optimization

Hi, I am working on a Rails project and hitting a performance problem. Here is the simplified db schema table gaming_platforms ( ~5 rows) id table games ( ~10k rows) id gaming_platform_id winner (black or white or n/a) black_id => online_players.id white_id => online_players.id table onlin...

creating a homepage in Rails?

I'm brand new to Ruby on Rails. I created a project by calling: Rails hello And I can access the project by going to http://127.0.0.1/hello, but when I leave off the "hello" from the URL I just get a generic homepage saying welcome to ruby. What's the best way to replace this homepage with a homepage for my project? Thanks! ...

Ruby Datamapper table inheritance with associations

I started learning Datamapper and what I liked about it was that I can write my models with real inheritance. Now I wonder, if it is possible to be more advanced about this: class Event include DataMapper::Resource property :id, Serial property :begin, DateTime property :type, Discriminator end class Talk<Event property :tit...

RAILS - paperclip don't work with Ajax

Hi, i have an application working fine with form_for updloading an image using paperclip. The problem is, because of the javascript security model, it cannot upload a picture via AJAX. I would like to know: what is the best approach, that really works with rails 2.3.x, to send file via aJAX using rails? IFRAME technique? swfupload? Any...

working with select boxes (RoR)

I created an application in Rails and generated two models, one for students and one for awards. rails students script/generate scaffold student given_name:string middle_name:string family_name:string date_of_birth:date grade_point_average:decimal start_date:date script/generate scaffold award name:string year:integer student_id:inte...

Creating and editing my element instead of using `new`

So, basically my 'index' action is a long list of elements output as a table with Rails, each one has a checkbox next to it. These elements are items in a catalog that will be line-items in a quote. A user can select as many checkboxes as they like, then click a button that says "Create a new Quote" it'll take the items they checked and...

net/http and posting data to Google Checkout

I'm trying to post form data to Google Checkout using the following code: x = Net::HTTP.post_form(URI.parse('https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/[merchant_number_here]'), @params) When I attempt to submit using this line, I get the following error: Errno::ECONNRESET in PaymentsController#create Connectio...

link for adding something to the session

Can I have a link that would add something to the session hash? For example if I had a link, can it do this when clicked: session[:items] << item I'll probably have to have the link trigger a JS file for that action, so I can update the session when the user clicks the link. ...

Date conditions using Search logic

The Rails plugin - Searchlogic, from binary logic - offers the ability to filter by date. I have my form set up like so... <% form_for @search do |f| %> <%= f.label :start %> <%= f.select :due_at_after, [[['','']],['November', '2009-11-01'.to_date],['December', '2009-12-01'.to_date]] %><br> <%= f.label :end %> <%= f.select :du...