ruby-on-rails

How to make SWF Call a Rails Ajax Request?

Hello, I'm writing an application that requires a flv video to be watched before displaying a proceed button to the next section of the site. Currently when the video ends the SWF player makes a POST request to the server marking the video as watched for the current user. Upon success the SWF player calls a Javascript function... Aler...

Why should I use Ruby on Rails ?

A friend of mine asked me if I was aware of Ruby on Rails ... and frankly I have heard a lot about it but know practically nothing about it. Any help will be much appreciated. ...

What is a good Ruby on Rails and PHP hosting?

I'm looking Ruby on Rails and PHP hosting service(shared space or a dedicated server). I would like to see two options first before buying one of them: PHP and can upgrade to Ruby on Rails later with additional cost Ruby on Rails and PHP I've looked at Dreamhost, Bluehost and RailsPlayground and all of them seem to have pros and cons...

Set current Time.zone in Rails?

Javascript on my page saves client UTC offset to the cookie. How do I use this cookie to create a TimeZone and assign it to Time.zone ? I need something like: before_filter :set_time_zone def set_time_zone Time.zone = ActiveSupport::TimeZone.new('my timezone', cookies[:timezone]) end except that the right part of this expression d...

How Does One Implement Dynamic 404, 500, etc Error Pages in Rails?

How does one implement dynamic, custom error pages in Rails? For example a custom 404 error page using your application.html.erb layout and some dynamic fields in the page. Also, how does one test this from a local machine? ...

Single Table Inheritance routing?

I have single table inheritance working just fine for my app. I have two user subtypes (Athlete and Company) that inherit the super-type User. Let's say I am listing all users, and want a link to each user's profile from this list. I want to link to the athletes controller if the type is athlete and the companies controller if the type...

How to refactor this Ruby (controller) code?

This is the code in my reports controller, it just looks so bad, can anyone give me some suggestions on how to tidy it up? # app\controller\reports_controller.rb @report_lines = [] @sum_wp, @sum_projcted_wp, @sum_il, @sum_projcted_il, @sum_li,@sum_gross_profit ,@sum_opportunities = [0,0,0,0,0,0,0] date = @start_date num_of_...

Where to put these code in a Rails web application?

I have some code that may just need to be called on a lot of places in the controller and model, where do I put these code in ? And how to call those methods then ? Thanks def self.number_of_months(start_date,to_date) # Get how many months you want to view from the start months (to_date.month - start_date.month) + (to_date.year - ...

Rails: has_many :through problem

Hi! I have problems with getting a has_many through association to work. I keep getting this exception: Article.find(1).warehouses.build ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :entries in model Article These are the models involved: class Article < ActiveRecord::Base has...

How to initialize the own class in rails?

I want to call InvoicingAndDelivery.report_lines, then give me an array of those results, but it isn't working. Any ideas? class InvoicingAndDelivery < Report include DateExtentions attr_accessor :report_lines, :tba_line, :sum_line def initialize(part_or_service_ids, start_date, to_date) # @report_lines = [] number_of...

Calendar structure with Reservations

Hello, i try to find a data structure for a calendar, which should offer the same functionality like googles calendar (want to build a structure in my own sql-database).. It should offer one-time, multiple times, hole day, date-from til date-to, events and so on... But it's a bit hard to find out the right strucure - do you know where ...

How to create an InstantRails clone

I'd like to create a new InstantRails-type app for Rails developers who use Windows. It would be free & open-source of course. Reasons: Use nginx over Apache, especially since the nginx guys are now releasing original Windows versions. Use the newest version of Rails. I haven't developed a Windows app before. Could anyone please pro...

What does middleware mean for Twitter and Scala?

Reference another SO question I had, I was given this article about Twitter moving from Rails to Scala, and in the article is this comment: By the end of this year, Payne said, Twitter hopes to have its entire middleware infrastructure and its APIs ported to the new language. Ruby will remain, but only on the front end. "We...

Framework for doing (Igoogle/Pageflakes/netvibes)-like application using Ruby on Rails

Anyone has any suggestions of a framework to help me create an Igoogle/pageflakes/netvibes like application using ruby on rails. I tried using apotomo for a few days, but couldn't make it work at all. If not possible to make using ruby on rails, do u have any suggestions on what to use? Thanks, ...

Getting started with tests in Rails

We have chosen to use rails to build a small project of ours. This is a really small project and will likely take six man-months or less. All people working on the project are new to Rails and have limited amount of experience in web coding. Our software is supposed to give users an easy-to-use interface to browse vast quantities of mea...

Disabling Rails logging from script/runner

Is there some way to disable all logging (whether from ActiveRecord, other parts of Rails, plugins, etc.) from a script running via script/runner? I've got a long data-loading script running, and it's generating an absurd amount of useless logging information. I'm not trying to change script/runner's environment (e.g., production, develo...

rails: accessing an instance variable in a js.erb file

I am trying to access an instance variable from a js.erb file. #controller def get_person @person = Person.find(1) respond_to do |format| format.js{} end end #get_person.js.erb alert('<%= @person.last_name %>') When I browse to [controller_name_here]/get_person.js ... I get a nil object error on @person. (I know Person.find...

ActiveRecord::StatementInvalid: Mysql::Error:

I tried to google hardcore to get what creates this problem, but nothing helped me, so i'm triing to write here! while doing: User.create(:name => "daniel") or User.new(:name => 'daniel').save in the rails console, i get this error ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '5' for key 1: INSERT INTO users (name, s...

Validating a node move in a nested set

I am creating a Category model and using the awesome_nested_set plugin (a replacement for acts_as_nested_set) to deal with the hierarchy. With awesome_nested_set, objects are created, then saved, and then placed within the set. As well, lft, rgt and parent_id are attr_protected so they cannot be written to directly. I am running into tw...

What is the best way to securely add administrative access to my rails website?

I think the answer is an admin login and then check if the user has an admin flag, but I also thought of some other related questions. Is it better to have an admin flag (attr_protected) in the same user table as non admins? or should i have an admin users table? Should I create a separate rails application for the admin users? This mi...