ruby-on-rails

web framework that will reduce number of lines of code

which framework helps in reducing the number of lines of code needed to create a web app? ruby on rails? php? asp.net mvc? jsp/servlet? django/python? I just don't like typing a lot of code especially if it's boilerplate. If I can write 10 lines of code versus 100 to get the same results, I think most people would prefer 10...right? ...

Thinking Sphinx with Rails - Delta indexing seems to work fine for one model but not for the other

I have 2 models User and Discussion. I have defined the indices for the models as below: For the User model: define_index do indexes email indexes first_name indexes last_name, :sortable => true indexes groups(:name), :as => :group_names has "IF(email_confirmed = true and status = 'approved', true, false)", :as => :approved_user, :typ...

JQuery + Rails + Select Menu

I want to have a select menu to change a field on a Customer dynamically, I've never used Jquery with a select menu, and I'm having problems. The code: <% form_for @customer , :url => { :action => "update" }, :html =>{:class => "ajax_form"} do |f| %> Pricing: <%= select :customer, :pricing, Customer::PRICING, {}, :onchange => "$('this...

How to store Ruby method references in a database?

I am writing my first rails app. It needs to aggregate some data from multiple sites and for each site I have a unique way of getting the data (some provide RSS, some JSON, for some I scrape the HTML etc.). These will run on schedule, probably as a rake task from cron. It seems logical to store the sites and relevant information in a mod...

Rails: show some examples of code from controllers, models and views

Hy, my controller example: class FriendsController < ApplicationController before_filter :authorize, :except => [:friends] ############## ############## ## REQUESTS ## ############## ############## ################## # GET MY FRIENDS # ################## # Get my friends. def friends @frie...

Rails: find_by_sql and PREPARE stmt FROM... i cant make it work

I have this query and I have an error: images = Image.find_by_sql('PREPARE stmt FROM \' SELECT * FROM images AS i WHERE i.on_id = 1 AND i.on_type = "profile" ORDER BY i.updated_at LIMIT ?, 6\ '; SET @lower_limit := ((5 DIV 6) * 6); EXECUTE stmt USING @lower_limit;') Mysql::Error: You have an error in your SQL syntax; c...

How do you pass self to class_eval in ruby?

...

How to install git only for installing plugins for rails from github?

How to install git only for installing plugins for rails from github? ...

Checking inherited attributes in an 'ancestry' based SQL table

I'm using the ancestry gem to help organise my app's tree structure in the database. It basically writes a childs ancestor information to a special column called 'ancestry'. The ancestry column for a particular child might look like '1/34/87' where the parent of this child is 87, and then 87's parent is 34 and 34's is 1. It seems possib...

Storing multiple checkbox values in database

Hi, I want to store multiple column values in table.Lets take a example .. What are your favourite colors? the choices can be red,blue,green, orange. So lets assume, the user selects atleast 2 values. Is there any way to store the multiple values in table. I have implemented by concatinating choices of users in a column in the table....

Robot/spam picture filter for Rails

I'm looking for a plugin or gem that has the picture of letters or words to filter spam and robots. Has anyone seen one of these for rails? ...

How to create a user customizable database (like Zoho creator) in Rails?

I'm learning Rails, and the target of my experiments is to realize something similar to Zoho Creator, Flexlist or Mytaskhelper, i.e. an app where the user can create his own database schema and views. What's the best strategy to pursue this? I saw something about the Entity-Attribute-Value but I'm not sure whether it's the best strategy...

Ruby way in model logic

Hi everybody! I'm junior rails programmer. I have some optimization questions about eager loading and Models at all. So I have such relationships: Program --< Subprograms --< Events --< Financings \--<Events --< Financings Program and subprogram is self-referrental sti models. I need to have a bunch of virtual fields in event...

Mysql::Error: Duplicate entry

Hi I have a model class Gift < ActiveRecord::Base validates_uniqueness_of :giver_id, :scope => :account_id end add_index(:gifts, [:account_id, :giver_id], :uniq => true) Action def create @gift= Gift.new(params[:gift]) if @gift.save ... else ... end end In the "production" mode, I sometimes get an error Active...

is this a secure approach in ActiveRecords in Rails?

Hello, I am using the following for my customers to unsubscribe from my mailing list; def index @user = User.find_by_salt(params[:subscribe_code]) if @user.nil? flash[:notice] = "the link is not valid...." render :action => 'index' else Notification.delete_all(:user_id => @user.id) flash[:not...

Mysql::Error: Duplicate entry

Hi I have a model class Gift < ActiveRecord::Base validates_uniqueness_of :giver_id, :scope => :account_id end add_index(:gifts, [:account_id, :giver_id], :uniq => true) Action def create @gift= Gift.new(params[:gift]) if @gift.save ... else ... end end In the "production" mode, I sometimes get an error Active...

Rails3 - will_paginate plugin strange output

I have the will_paginate plugin working in an application, but when I paginate a resource it just spits out the HTML as text, doesn't provide links to the next pages and such. And when I manually type in the URL the plugin is working it just doesn't make <%= will_paginate @products %> into links such as next 1 2 3 ... last This is the ...

rails: read cookie set date

Hello. How can i read cookie set date? In rails api I can not find this information, google also doesn't have... ...

How to call model /action mailer methods from a rake task in rails 2.2.2

I want to call few model methods and send emails through my rake task. Any help would be apreciated ...

how do I associate one model twice to another

Hi im making a small site to help me and friends learn languages. Typical use: Adam is english but is learning japanese. Adam can practice his japanese by writing and submitting articles written in japanese. Adam cant (not allowed to) submit any articles written in his native language. Adam can read articles (written in English) by ot...