ruby-on-rails

Cloud-aware programming and help choosing a good framework

How can i write a cloud-aware application? e.g. an application that takes benefit of being deployed on cloud. Is it same as an application that runs or a vps/dedicated server? if not then what are the differences? are there any design changes? What are the procedures that i need to take if i am to migrate an application to cloud-aware? ...

Obtain the stored values of a modified Rails model object

Is there a way to obtain the stored value, that is, the one in the database once the instance has been modified? The problem I'm trying to solve is get the stored slug of an object that failed to save to be able to regenerate the URL. ...

RAILS :"session contains objects whose class definition isn\'t available."

Session contains objects whose class definition isn\'t available. Remember to require the classes for all objects kept in the session I am trying to integrate http://github.com/binarylogic/authlogic for authentication into my rails application . I follwed all the steps into mentioned in the documentation . Now i seem to be getting thi...

Rails: saving a string on an object -- syntax problem?

Hey there, I am trying to write a simple function to clean a filename string and update the object. When I save a test string it works, but when I try to save the string variable I've created, nothing happens. But when I return the string, the output seems to be correct! What am I missing? def clean_filename clean_name = file...

Using URI-fragments in Ruby on rails routing

RoR application can generate URL such as /post/10. But now I want to create a site, which works with URI-fragments like gmail. For example gmail uses the following URLs https://mail.google.com/mail/?shva=1#sent https://mail.google.com/mail/?shva=1#label/books I need to generate URL such as /#/post/10, where controller = "post", action ...

Template Error on Form_for in Rails

I have an nested model student that belongs to a high_school. The problem is that when I go to create a new student (/high_schools/1/students/new) I get this error: No route matches {:action=>"destroy", :controller=>"students", :high_school_id=> # <HighSchool id: 1, name: "cool place", ... } <%= form_for @student, :url => high_school_...

Is there a better way to write the find_messages_by_slug_or_404 method?

In my messages_controller I have the following private method: def find_message_or_404(slug) message = user.messages.find_by_slug(slug) if message.nil? raise Error404 end message end I find it not elegant and not very Rubist. Is there a way to improve it? ...

Rails ajax jquery problem

Ok I have this problem I'm trying to use Jquery to load a partial in replace of a listed object. index.html.erb <div class="style_image_<%= style.id %>" > <%=link_to image_tag(style.cover.pic.url(:small)), style %></div> loadshow: $(function() { $(".style_image_<%= style.id %> a").click(function() { $(".style_image_<%= style...

email-spec destroys my rake cucumber:all

At the beginning this worked fine: $ rake cucumber:all But then $ script/plugin install git://github.com/bmabey/email-spec.git remote: Counting objects: 162, done. remote: Compressing objects: 100% (130/130), done. remote: Total 162 (delta 18), reused 79 (delta 13) Receiving objects: 100% (162/162), 127.65 KiB | 15 KiB/s, done. Resolvi...

Quick help refactoring Ruby Class

I've written this class that returns feed updates, but am thinking it can be further improved. It's not glitchy or anything, but as a new ruby developer, I reckon it's always good to improve :-) class FeedManager attr_accessor :feed_object, :update, :new_entries require 'feedtosis' def initialize(feed_url) @feed_object = Fee...

Gracefully exiting from thread in Ruby

Hi, I am trying out Mongrel and using the following code: require 'rubygems' require 'mongrel' class SimpleHandler < Mongrel::HttpHandler def process(request, response) response.start(200) do |head, out| head["Content-Type"] = "text/plain" out.write("Hello World!\n") end end end h = Mon...

Determining URLs updated via a series of commit logs

I'm working on a project where I programmatically need to know when a URL has been changed by a developer, post or during deploy. The obvious answer may be to curl the URL one day, save the output, then curl again in x days and diff the two. That won't work in my case, as I'm only looking for changes the developer made. If the site is...

rspec install failed

screen: E:\ir\InstantRails\rails_apps>gem install rspec Attempting local installation of 'rspec' Local gem file not found: rspec*.gem Attempting remote installation of 'rspec' ERROR: While executing gem ... (Gem::GemNotFoundException) Could not find rspec (> 0) in the repository my env: InstantRails 1.3a on windows thanks for he...

How do I create and use a junction table in Rails?

I have the following data: A post called Hello has categories greet Another post called Hola has categories greet, international My schema is: create_table "posts", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "categories", :force => true do |t| t.string "name" t...

How to create this MongoMapper custom data type?

I'm trying to create a custom MongoMapper data type in RoR 2.3.5 called Translatable: class Translatable < String def initialize(translation, culture="en") end def languages end def has_translation(culture)? end def self.to_mongo(value) end def self.from_mongo(value) end end I want to be able to use it l...

Search french via Thinking Sphinx in ROR project

Hello everyone: How can I use sphinx to search french words which the entries in the db is actually english? The situation is: I have a ROR project with a table in the db called "categories", and the category names are in english, category has many "question" entries. In localization file config/locals/fr.yml, these categories were t...

How to: Searchlogic and Tags

I have installed searchlogic and added will_paginate etc. I currently have a product model that has tagging enabled using the acts_as_taggable_on plugin. I want to search the tags using searchlogic. Here is the taggable plugin page: http://github.com/mbleigh/acts-as-taggable-on Each product has a "tag_list" that i can access using Pr...

memcached never expired in rails?

It's very strange that the session will never expire if i use memcached store even i set config.action_controller.session :session_expires => 1.seconds.from_now And I use extended_fragment_cache to cache fragment, I meet the same problem <% Cache "my_page", {:expires => 1.minutes} do ... %> never expired! Anyone know where's the pro...

Create/Modify a Virtual Host and Reload Apache from Inside Rails App

My application is a set of two rails applications. Based on some parameters in first app. I need to setup the virtual host of the second app. I just need to change the ServerName and ServerAlias in apache VH and enable the site using a2ensite and then 'apache2 reload '. How can I do this from within a rails application? Thanks, Imran ...

Rails 2 support after Rails 3 has been released

Is there some plan or estimate about how long will Rails 2 be supported after Rails 3 has been released? I wanted to ride the wave and move to Rails 3 right away, specially for projects that may take 4 or 6 months to finish (so that they would probably be released with Rails 3.0.0 final) but I've found many things still not working, man...