ruby-on-rails

Facebooker extended permissions??

Facebook gives access to users' emails via the extended permission. There's also a way in JS and PHP to force users to grant the permission when they accept the app's TOS - http://wiki.developers.facebook.com/index.php/Extended_permissions Is there a way that I can do this with Facebooker? Regards.. ...

Using fields from an association (has_one) model with formtastic in rails

I searched and tried a lot, but I can't accomplish it as I want.. so here's my problem. My models are: class User < ActiveRecord::Base has_one :profile accepts_nested_attributes_for :profile end class Profile < ActiveRecord::Base attr_accessible :user_id, :form, :title, :name, :surname, :street, :housenumber, :zipcode, :place, :...

How do I add custom buttons to Formtastic?

I'm using the Formtastic Rails gem in my app and its been great, but I would really like to add a second button, other than the bundled "commit" button that redirects back. I can't seem to find any information on how to add a custom button. Any information would be greatly appreciated! ...

Mapping legacy database columns in a rails project

We are creating a rails application for an already existing database. We need to map some database tables together. Suppose we have three tables: event, event_groups and event_to_groups. There are some events, there are some groups, and each event can be assigned to one or more groups. How do I model this relation in rails? eg: Ex...

How to override the attr_protected?

I have STI implementation as follows: class Automobile < ActiveRecord::Base end class Car < Automobile end class Truck < Automobile end class User < ActiveRecord::Base has_many :automobiles accepts_nested_attributes_for :automobiles end I am creating a list of automobiles for a user. For each automobile, the UI sets the type fi...

Rails - number of rows in a file

Hey. How can I get a total number of rows in a file (do not want to do it with loop). I'm reading CSV file. Example 1 CSV.open('clients.csv', 'r') Example 2 FasterCSV.foreach('clients.csv') Thx. ...

Help porting a bit of Prototype JavaScript to jQuery

I have already implemented some AJAX pagination in my Rails app by using the example code for the will_paginate plugin--which is apparently using Prototype. But if I wanted to switch to using jQuery for future additions, I really don't want to have the Prototype stuff sitting around too (yes, I know it's possible). I haven't written a l...

how do I redirect from a subdirectory to another directory, but strip off the original subdirectory from the URI using mod_rewrite

I have a Ruby on Rails app running on 12001. I am currently redirecting a subdomain to 127.0.0.1:12001 using some ReWriteCond detection. Now I want to redirect my subdirectory to that rails app. http[s]://domain.com/redmine to 127.0.0.1:12001 The current rules apply REQUEST_URI to the above rails path, but I need to strip "/redmine...

Problems using a legacy database with a new rails application

What are the usual problems / stumbling blocks / issues / drawbacks when using a legacy database with a new rails application? We have to decide between using an old database or writing migration scripts to bring data from old database to new database following rails conventions. What would you suggest? ...

Paypal subscriptions IPN - problem with users subscribing multiple times

I'm using paypal subscriptions and the instant payment notification (IPN) to handle subscribers on my site. For the most part it works well but there is one occasional problem I've encountered. Usually if a user cancels their subscription, I wait for the "end of term" (subscr_eot) notification before disabling access to my site. So if...

Call named routes in CakePHP as the same way in Ruby on Rails

How can I call a route (in the view) in CakePHP as the same way in Rails? Ruby on Rails routes.rb map.my_route '/my-route', :controller => 'my_controller', :action => 'index' view link_to 'My Route Name', my_route_path CakePHP routes.php Router::connect('/my-route', array('controller' => 'my_controller', 'action' => 'index')); ...

Regarding Authlogic and page redirection.

I am using authlogic for authentication in my Rails app. Have named routes for the frequent actions, viz: map.login "login", :controller => "user_sessions", :action => "new" map.logout "logout", :controller => "user_sessions", :action => "destroy" map.register "register", :controller => "users", :action => "new" map.ed...

Ruby-on-rails: routing problem: controller action looks for show when it should look for finalize

background: trying to use the twitter gem for ruby-on-rails. in routes: map.resources :twitter_sessions map.finalize_twitter_sessions 'twitter_sessions/finalize', :controller => 'twitter_sessions', :action => 'finalize' (twitter_sessions is the controller for the twitter sessions in my app). The view has one file new.html.erb and i...

How can I override the attribute assignment in an active record object?

I know you can do this with virtual attributes, but what if the column actually exists? For example, my model has a raw_topic column. When raw_topic is set, I want artist and song_title to be set based off of raw_topic's contents. Ideally, I'd like to override the raw_topic= method, but rails doesn't seem to like that. What's the prope...

action mailer gem and tlsmail gem not working in heroku after GIT PUSH HEROKU

I'm using heroku as my host..It was working fine. Then I installed action_mailer_tls and tlsmail. Then I comitted it and pushed it heroku.. After that I got error in myapp.heroku.com. The error is /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- smtp_tls (MissingSource...

jquery.form vs remote_form

Hi, Could you tell me pros and cons of using jquery.form plugin and basic remote_form_for from RoR? What is better? ...

Site to Site VPN with Rails

First of I'm very sorry but this questions is not so so specific. All I am looking for is a tutorial or a resource for creating a site-to-site VPN. Actually, I not even sure if that is what I should call it. I live in China and I want to access youtube and stuff. And I don't want to buy a proxy service so I'm trying to make my own VPN o...

How to get jQuery to work with Prototype

Ok so here is the situation. Been pulling my hair out on this one. I'm a noob at this. Only been using rails for about 6 weeks. I'm using the standard setup package, and my code leverages prototype helpers heavily. Like I said, noob ;) So I'm trying to put in some jQuery effects, like PrettyPhoto. But what happens is that when the pag...

how to monitor if the connectivity between the rails apps and mysql database is established

How do we monitor that the connectivity between the rails app and the database is established. will rails try to re-connect the connection with mysql if it closes? ...

Broken pipe error in rails with memcached

I keep running into this error MemCacheError (Broken pipe): Broken pipe on my Rails app and I can't figure out why. When I access memcached via Rails.cache in my controller, the first 1 or 2 read/writes always seems to throw the broken pipe error. But when I access memcached by creating a new object, ActiveSupport::Cache::MemCacheStore...