ruby-on-rails

How to create a zip archive using Ruby on Rails?

I have a bunch of files in a directory. I want to zip some of them together into a zip archive. I can see there are various solutions for doing so. I could use a gem such as rubyzip or run exec and just use a command line tool. This is going to impact an important part of the system I'm working on so I'd love to have some feedback and...

Including Join Model Attributes in Serialization

Imagine a service where a User :has_many Events :through an Interest join model, and that there is an Interest#attending flag to indicate whether the user plans on being at the event. If I want to return a list of events, but also include the value of the #attending flag for the current user, I could do this: <interests> <interest> ...

define javascript functions on iframe facebook app inside <fb:serverfbml> tag

Hi all, How we can define JS function on inside ? I tried to load file javascript on the end tag , but I still can't call the function from javascript file. Here the FBML tag <fb:serverfbml> <script type="text/fbml"> <fb:fbml> <a href="#" id="this" onclick="do_colors(this); return false">Hello World!</a> <script src=...

What is Ruby on Rails ORM in layman's terms? Please explain

I am having trouble understanding ORM in Ruby on Rails. From what I understand there is a 1:1 relationship between tables/columns and objects/attributes. So every record is an object. Also what exactly is a Model? I know it maps to a table. What I'm really after is a deeper understanding of the above. Thank you in advance for your help ...

recommendations for two challenging web app problems

I'm looking for recommendations for vendors - quite possibly start-ups - who can help with two challenging requirements for an app I'm building right now. We're really open to new and innovative solutions to these two challenges. I've got a lot of control in terms of dictating choice of browser, selection of hardware, and even choice of ...

Authentication Ruby on Rails...

I am building a project management app and I am not sure which is the best/correct authentication model to implement given I am new to Rails (and programming in general). Here is what I am trying to do. I want to be able to add a "client" to the application and then multiple projects to a client. I would like to be able to add users (t...

Modifying rails route helper

I'd like to modify the behavior of the rails route helper *_url for a single route/page. Here's what I'm try to do: User visits: http://test1.myapp.com/account All the *_url routing helpers resolve to http://test1.myapp.com/ as normal. But, then if the user goes to https://myapp.heroku.com/account/billing?id=test1 I'd like all t...

Have rails ignore a specific path

I have a shared/ folder in my my_app/public/ folder and when attempting to access it via www.my_app.com/shared, I see: no route matches '/shared', :method => 'get' This makes sense, but I want rails to ignore this folder and just let me use Apache to render a standard directory listing here. Any way to do this? ...

Show ActiveRecord objects like table in ./script/console

How to display ActiveRecords like >> Role.all +----+-----------+-------------------------+-------------------------+ | id | name | created_at | updated_at | +----+-----------+-------------------------+-------------------------+ | 1 | Admin | 2009-11-16 21:22:59 UTC | 2009-11-16 21:22:59 UTC ...

Question about rails webservice and authentication

What I am doing is rails web service API that let user create traveling log when they access any sites, by using firefox plugin.For this requirement I needed 2 things. skip_before_filter :verify_authenticity_token in specific controller (Because I let user create it through API not the form, so I disable this). user have to provided us...

Rails route globbing vs. escaping?

Hi. I'm trying do something like this: map.goto '/g/*extra', :controller => 'goto', :action => :show Where extra is a path component, e.g.: redirect_to goto_url( employee_path(employee) ) What I get is: http:://www.example.com/g/%2Femployee%2F123 What I want is: http:://www.example.com/g/employee/123 So my question is: altho...

pass form builder in remote_function in rails ?

hi all i have select box where on change i need to grab the value and via remote function get some field names from db and then generate those field further down the form depwning on whatoption from the select box is chosen. The problem is is that the fields are in a f.form_for so are using the formbuilder f that has the select box in...

Displaying Rails response time in view

I'm trying to set up custom Pingdom monitoring of my Rails application and would like to craft an XML response that looks like this: <?xml version="1.0" encoding="UTF-8"?> <pingdom_http_custom_check> <status>OK</status> <response_time>210.22</response_time> </pingdom_http_custom_check> Where the response_time value is the time tak...

How to detect if rails is at the root url?

What I want is seems simple. In my application helper i setup this module ApplicationHelper def isroot if root_url @container = "mainbox" else @container = "maincontainerbox" end end end in my application layout i have this <div id="<%= isroot %>"> How do I find out if my application is at the homepage. if not do something els...

Rails add custom eager load

I have a number of custom find_by_sql queries in Rails. I would like to use eager loading with them but there doesn't seem to be a good way to do this. I have seen the eager_custom.rb file floating around and it doesn't seem to work with Rails now. It appear Rails does eager loading differently now, using 2 queries (the regular query ...

Access rails session information by session id

I'm using the default cookie based session store. Basically, I'm using heroku and I need to go from my app: http://test1.myapp.com over to heroku for one page: http://myapp.heroku.com/billing - so I need to access the session when I go to the heroku url. I'd like to access the session[:user_id] on the heroku page, but when is go to ...

Triggers/Callbacks in Ruby on Rails

Hello all, We are creating a system in Ruby on Rails and we want to be able to offer our users a bit of control about notifications and actions that can take place when some pre-defined trigger occurs. In addition, we plan on iterating through imported data and allowing our users to configure some actions and triggers based on that data...

Updating one select box based on another (Ruby on Rails)

Hello, I'm new to Ruby on Rails, and need some help. I'm working on a web application which can be used to keep track of cars. There are two models, one which represents makes (Saab, Honda, Toyota, etc) and another which represents models (Civic, Miata, PT Cruiser, etc). They have a "has_many" relationship: script/generate scaffold mak...

Loading and managing reference data in Rails

Most of the apps I've worked on have had some kind of reference data stored in the database, for example categories, zipcodes, area codes etc... this is information that's going to change very infrequently. Most of the time you want to load some kind of display name, and that's it. Currently this isn't causing me too many headaches, it...

Is it worth learning C as a web developer? Will I ever use it?

As a web developer, is it worth me learning the programming language C? Will I ever need to use it? I am currently using PHP and Ruby on Rails. Thank you in advance to all you good people out there ...