ruby-on-rails

Ruby on rails authlogic config (get rid of capitalization check)

The authlogic rails gem is doing a LOWER in the sql query. SELECT * FROM `users` WHERE (LOWER(`users`.email) = '[email protected]') LIMIT 1 I want to get rid of the LOWER part since it seems to be slowing down the query by quite a bit. I'd prefer to just lower the case in the code since this query seems to be expensive. I'm not sure w...

config.cache_classes = true in production mode has problems in IE

Hi Dears, In my rails app. I am using link_to_function to bring an ajax tabs in one page.Everything works fine in Moazilla and other browsers. But in IE the tabs are not loading only when the server is started in production mode(doesn't matter whether it's webrick or mongrel). In development mode everything is fine. So I figured out tha...

Rails plugin for Group of users

Hello, My Rails application have a User model and a Group model, where User belongs to a Group. Thanks to this, a user can be a admin, a manager, a subscriber, etc. Until recently, when for example a new admin need to be create on the app, the process is just to create a new normal account, and then an admin sets the new normal account...

validation before ajax form submission

How do i introduce validation before remote_form_for submits? I have javascript function called validateForm(). I am able to call it before the AJAX request process. I tried to use return false and event.preventDefault. But there seems to be no effect. Here is what my code looks like <% remote_form_for :customer, :update =>"uxScreenLoa...

Rails link from one model to another based on db field?

Hi Everyone, I have a company model and a person model with the following relationships: class Company < ActiveRecord::Base has_many :kases has_many :people def to_s; companyname; end end class Person < ActiveRecord::Base has_many :kases # foreign key in join table belongs_to :company end In the create action for the perso...

[Rails] ActiveRecord using Safari Sqlite

Hi, I am build a webapp for iphone using Phonegap, and I want to create a DB on the device and not on my server. I've seen that there is a Safari Sqlite database, but I haven't been able to find any information about using this database with active record. Does someone knows how to do so? Best, Gregory ...

RAILS: How to get has_many associations of a model

Hi, how I can get the has_many associations of a model? For example if I have this class: class A < ActiveRecord::Base has_many B has_many C end I would a method like this: A.get_has_many that return [B,C] Is it possible? Thanks! ...

Mongomapper - bootstrapping techniques

I've just begun creating a rails application using mongomapper for my models. I'm wondering what solution should I use for bootstrapping my app with it. All my previous experience is with ActiveRecord & PostgreSQL, in which I have used several gems for bootstrapping. The one I liked the most was bootstrapper (+ factorygirl + faker). Do...

Rails Atom builder xml.tag!("activity:object-type") error

I am creating a activity stream of my feeds according to the http://activitystrea.ms standard. I am using rails atom builder to create a valid atom feed, but when I use xml.tag!("activity:object-type", "http://activitystrea.ms/schema/1.0/person") the atom feed goes blank.On seeing the source I find the correct xml format from what ...

Override a Rails Engine controller action

Hello, i'm using a Rails engine, but i need to customize some controllers actions. I actually forked the engine, and implementing those customizations into my own fork, but i was wondering if there is an official way in Rails Engines to override and customize controllers. ...

Rails with passenger only runs in development

Hey, I have a problem on one of our webservers. I'll try to explain it as clear as possible, but I'm not 100% aware of all the configuration of the server. There are 2 sites running next to eachother (blcc_preprod and blcc_prod), so in the 'sites-enabled' of apache this i have a file 'blcc' like this: <VirtualHost *:80> DocumentRoo...

How to convert a table column to another data type

I have a column with the type of Varchar in my Postgres database which I meant to be integers... and now I want to change them, unfortunately this doesn't seem to work using my rails migration. change_column :table1, :columnB, :integer Which seems to output this SQL: ALTER TABLE table1 ALTER COLUMN columnB TYPE integer So I tried d...

Ruby on Rails can't find 'label'

Hi trying to make a Registration page with Ruby on rails using the tutorial found here http://rails.francik.name/week4.html having trouble getting the page to work after adding <h1>Register</h1> <enter code here%= error_messages_for :user %> <% form_for :user do |f| %> <p> <%= f.label :screen_name %>: <%= f.text_field :scree...

Authlogic OpenID: Fetching E-Mail from Provider.

This is a really weird problem: I have set up the authlogic_openid_selector_example app. When i register, the email id is not returned by the openid provider the first time. But if i delete the account and register again, the email id is returned. How do i fix this problem? I have hosted my version of the app here: http://pingauthtest.h...

rails, mysql charsets & encoding: binary

Hi, i've a rails app that runs using utf-8. It uses a mysql database, all tables with mysql's default charset and collation (i.e. latin1). Therefore the latin1 tables contain utf-8 data. Sure, that's not nice, but i'm not really interested in it. Everything works fine, because the connection encoding is latin1 as well and therefore mysq...

Replicating object function across various model files in Ruby on Rails

I am looking to replicate a given object function across various model files As you can see below, the 2 things I need to vary across the model are 1) the "guser" string 2) the self.xxx SIMPLIFIED CODE SAMPLE: def self.get_all statement="SELECT * FROM gusers WHERE" results = results + self.find_by_sql(["#{statement...

Using unless in rails uniqueness validation

I am just starting out in Rails, and trying to develop a simple application. I need to validate three values submitted to the application - each must meet the same validation criteria. The validation is pretty simple: Value is valid if unqiue, null or equal to "p" or "d". The following gets me halfway there: validates_uniqueness_of :...

Ruby (Rails): export db data for SPSS

I have a Rails application to do web surveys. It stores answers to multiple-choices (fixnum) questions into sqlite3. Is there any ruby gem that I can use to export my data into spss format ? I'd like to be able to export for SPSS version prior of 16/16 or up. My SPSS export needs to include two files: a syntax file (survey_name_SPSS_s...

Debugging on the production server in Rails

how do you effectively debug on live server in rails, whether on a beta/production server? I tried modifying the file directly on the server, and restarting the app, but the changes does not seem to take effect, or takes a long time to (caching?) I also tried to do "script/server production" locally, but that is very slow The other o...

Sanitizing User Input with Ruby on Rails

I'm writing a very simple CRUD app that takes user stories and stores them into a database so another fellow coder can organize them for a project we're both working on. However, I have come across a problem with sanitizing user input before it is saved into the database. I cannot call the sanitize() function from within the Story model ...