ruby-on-rails

renaming routes (map, link_to, to_param) in rails

Hey there, I'm having a little issue...I setup a rails application that is to serve a german website. To make use of Rails' internal pluralization features, I kept all my models in english (e.g. the model "JobDescription"). Now, if I call "http://mysite.com/job_descriptions/", I get all my job_descriptions....so far, so good. Because I ...

Getting objects updated in last 10 seconds from ActiveRecord's find

Hi, I'd like to get the objects that are updated in the last 10 seconds from the ActiveRecord's find. I tried doing this @chats = Chat.find(:all, :conditions => ["updated_at > ?", 10.seconds.ago] ) as well as @chats = Chat.find(:all, :conditions => ["updated_at > ?", Time.now-10.seconds] ) and even @chats = Chat.find(:all, :con...

[Rails] How can I have several applications use the same authentication system?

I need to build several Rails applications for one client. I would like to give them all the same user authentication system so that users will not have to remember separate login credentials for each app. These are strictly internal applications. OpenID is not an option for this organization. I am thinking of creating a central Rails a...

Does anyone know any gems/plugins/tutorials related to exporting events to iCal, Google Calendar, Outlook from a Rails application?

I am trying to figure out if there is already a plug in that does the interaction with iCal, Google APIs that I can use or do I need to just get my hands dirty and write it myself. If anyone knows of good resources that I can look at that could help me with the implementation, that would be good as well. I am new to RoR and I have be...

Rails - Should I use boolean fields or relational table?

User model has three keys: is_master, is_standard, is_guest because I originally wanted to use activerecord boolean methods like is_master? or is_power?. However, if it would be better to create a UserType relationship and create my own methods like this: def master? return true if self.user_type = 1 end What's the best practice o...

add_column for references (Rails)

I have the following Rails migration which works perfectly (irrelevant pieces removed): create_table :comments do |t| t.text :body t.references :post end Now I'd like to add an author column to my comments table (which is the userid of a user), but I have no idea how to do it (I'm tempted to just write the MySql-specific syntax us...

PHP/Django/Rails/Flex hybrid demo - need project idea

Let's say you were crazy enough to want to try to combine a number of different technologies just to show that you could do so - what kind of app would lend itself to this type of project as a demo for a potential employer? Specifically I'm thinking of combining the following technologies: PHP/Django/Rails/Flex Does this sound ridicu...

protect_from_forgery vs. Firefox

I've recently switched from storing session data in a cookie to storing it in the database. Now every POST request causes an ActionController::InvalidAuthenticityToken error. It only happens in Firefox, and only on my home machine (I tried it out at work today in the same version of FF and everything was fine). This leads me to believ...

How different is CakePHP from Ruby on Rails?

I almost never hear the word CakePHP without hearing the word Rails shortly afterwards. Are these two frameworks mainly similar based on how they adhere to the MVC model or do they have other significant similarities/differences? One of the main attractions of Rails for me is how easy it is to do Ajax. Would that also be true of CakePH...

How do you GET a RESTful resource by something other than ID?

There may be situations where I would need to find an object by parameters other than ID. What is the proper RESTful way to do that? For example I might want to find a User by username and password, so the strictly RESTful "GET /users/1" wouldn't work. According to the Rails docs this is the URL pattern for getting all the instances of...

Rails requires RubyGems >= 0.9.4. Please install RubyGems

Having the same problems as this post, except I don't think the solution is the same unfortunately. I'm getting this error message: Rails requires RubyGems >= 0.9.4. Please install RubyGems when I run a script/runner job in Cron, but it works perfectly fine when I run it in a terminal on the same server. The rails server also runs f...

Cycling through array of objects within view in Rails: unexpected behaviour

Hi. I've got a simple calendar displaying some events, that's not quite giving me the expected results. Here's the code: <!-- Begin Calendar --> <%= calendar(:year => @year, :month => @month, :first_day_of_week => 1) do |d| output = [] output << render_calendar_cell(d.mday) if d.wday == 1 @garden.plants.collect do |p|...

Letting something happen at a certain time with Rails

Like with browser games. User constructs building, and a timer is set for a specific date/time to finish the construction and spawn the building. I imagined having something like a deamon, but how would that work? To me it seems that spinning + polling is not the way to go. I looked at async_observer, but is that a good fit for somethin...

What resources are there for A/B split-testing in Rails?

Some information on A/B split-testing: http://startuplessonslearned.blogspot.com/2008/09/one-line-split-test-or-how-to-ab-all.html http://www.37signals.com/svn/posts/1525-writing-decisions-headline-tests-on-the-highrise-signup-page I could do this in a Rails app with a simple case or if statement in my views, but that gets to be a lo...

Is it ok to use different different OSes for production/development servers with Rails?

Say, I love Debian+mod_rails and run it on my laptop which is my development platform. Yet, I am deploying to a production server running Ubuntu+mod_rails. Is it better in a long run if I install Ubuntu on my laptop or are the problems with deployment so miniscule I can go with whatever the hell I like on dev. machine? Thanks. ...

Two foreign keys with ActiveRecord? [rails]

I have a User class with reference to a Message class. The message class has a user_id (which is the sender) and a receiver_id. So in the User class I have has_many :messages has_many :messages, :foreign_key => "receiver_id" and then in the Message class I have belongs_to :user The first relationship -- via user_id -- goes p...

How do you test whether a model has a given method in Rails?

I would like to implement the method User.calculate_hashed_password. I'm trying to use the Shoulda testing library which works with Rails's built-in testing tools, so an answer related to Test::Unit would be just as good as one related to Shoulda (I think). I'm trying to figure out what I need to test and how I should test it. My initia...

Lua on Rails?

Is there a library like Rails for Lua? ...

How I turn an average desktop PC into server for hosting a website using Ruby on Rails?

What is the best way to turn an average desktop PC into server for hosting a website using Ruby on Rails? I am open to changing operating systems, buying parts if I need to, using whatever Database People recommend and any software. Here are the approximate details of the computer: The computer is an HP Desktop with 1.86GHz Duo Core...

Creating Plugins in rubyonrails.

I am creating a plugin which involves a controller, model & views. while i can move these files from the vendor/plugin directory to app/controllers, models & views respectively. now i can run my controller & model just by copying them in lib folder of vendor/plugins/plugin_name/lib and they are directly accessible, but my views are not ...