ruby-on-rails

How can I make a searchlogic named scope return DISTINCT (non duplicates?)

I have a searchlogic that searches for not_null on an association that can occur many times, but I only want to display one UNIQUE/DISTINCT instance of the object: Company.contact_emails_id_not_null I only want one Company, no matter how many contact_emails are associated to that Company :through => :contacts ...

Why scss is not blowing up for wrong css value

I am using scss with haml in my rails3 project. I mistakenly typed zindex: 99999 instead of z-index: 9999 SCSS did not blow up. I thought one of the benefits of using haml/sass/scss was not invalid css values are not allowed. ...

How can I cache Model objects in Rails?

Hi, Is there a technique that I can use in Rails so that whenever a simple "find" is performed on a Model object, memcached is first searched for the result, only if no result is found will a query by then made to the database? Ideally, I'd like the solution to be implicit, so that I can just write Model.find(id), it first checks the c...

Using Yahoo! as an OpenID Provider in a Rails App

Hello All, So, I'm attempting to integrate Yahoo! into my Rails application as an OpenID provider and I'm having some trouble. I asked this question on Stack Overflow already, but it's not exactly the same question. I've already asked my current question here on RailsForum, but it hasn't gotten answered yet so I thought I'd repost it he...

"Super from singleton method that is defined to multiple classes is not supported"

I'm trying to use the Steam Condenser library with Ruby 1.9.2 and Rails 3. I have the following code: require "steam/servers/source_server" class HomeController < ApplicationController def index server = SourceServer.new(IPAddr.new("127.0.0.1"), 2000) server.init @m = server.get_players end end but for some reason...

How can I group AND's and apply an OR between groups in searchlogic in Rails?

I want to do the equivalent of (A<y AND B>x) OR (C < y AND D>x). how can i do that? Right now, I am creating separate queries: @companies_with_email = Company.contact_emails_date_sent_gt(@monday). contact_emails_date_sent_lt(@friday). find(:all, :select => "distinct companie...

How can I update an association (has_one) in a Rails AR using link_to_remote?

This is what I have in my view: <%= link_to_remote "Responded - Positive", :url => contact_path(@contact, :status => 'positive response'), :update => "status" %> This is what I have as a route: map.resources :contacts, :has_one => :status_contact Here is what I used in my controller: def create @status_contac...

How do I model a table tennis match in rails.

I am attempting to model a table tennis match in rails. Here is what I have: Game Model: team_1_score team_2_score team_1_id team_2_id Team Model: game_id player_id Player Model: Name So each game will consist of 2 teams (of either 1 or 2 players each). Then I was planning on linking game to player with has_many, :through. I don'...

Starting off with Ruby and Ruby on Rails

Hi, I am interested in building web applications using Ruby on Rails. I surfed the Internet and found out that I need to have a prior knowledge of the Ruby language. So can you please suggest some good books, online resources to start off with Ruby first and then Ruby on Rails? Thanks, Rakesh. ...

Rails 3 is messing with my flash!

I have a flash_helper that I inconveniently downloaded from some web tutorial, which is now coming back to whack me on the head. On the good side, I'm sure the many talented coders here will find this easy. :) # application_helper def flash_helper [:notice, :warning, :message].map { |f| content_tag(:div, flash[f], :class => f) if flash[...

Feed Parsing In Rails

Hi, I am working on Ubuntu 10.04 and I am using feed-zirra to parse RSS feeds and I have MySQL database. I am trying to parse RSS feeds from Times of India Top Stories. There seems to be problem with the first link, I am sure TOI guys will correct it soon. But anyway, I dont want to face similar error later so thats why I want to ask ...

Advanced Feed Parsing in Rails

Hi, I am a newbie to rails and I have been watching Rails Casts videos. I am interested to know a little bit more on FeedZirra (Rails casts episode 168) and especially feed parsing. For example, I need to Parse feeds from Telegraph and Guardian I want to put all the sports news from both the newspapers in one table, just football new...

How to access session of one site from other site

Hi there! I have website w1 written in rails using auhtlogic for authentication and w2 in PHP(say), I want w2 to access session information stored by w2 and login user into w2 and also retrieve user_id from session. ...

How can I override the default validations that come with Authlogic?

I have my own password/login rules that I want to implement such as: Password: At least one number, one lower case character and one upper case character Login: Alphanumeric and between 4 and 15 characters long etc... Currently when I do not enter a password and login in my form, I get the following errors (from Authlogic's default ...

Force SSL using ssl_requirement in Rails app

I have a Rails application which need to run under SSL. I tried ssl_requirement but seems I have to type in all the actions in every controllers. Is there any method that I can add a before_filter in application controller with ssl_requirement, so that the apps will redirect to https automatically when user request is in http? Thanks a...

Determine what attributes were changed in Rails after_save callback?

I'm setting up an after_save callback in my model observer to send a notification only if the model's published attribute was changed from false to true. Since methods such as changed? are only useful before the model is saved, the way I'm currently (and unsuccessfully) trying to do so is as follows: def before_save(blog) @og_publishe...

rails: filter categories where there are at least one article

Hi, I have articles and categories in a n:m relation: I looking for a find statement on the Category Model so that I can get all categories witch consist at least one article. Should be easy, but I didn't find a efficient solution, without searching retrieving all the articles. Thanks, Maechi ...

Plugin vs Engine in Rails 3, shipped as a gem

In the documentation for Rails::Plugin (for Rails 3), I'm reading the following: "... you actually cannot declare a Rails::Engine inside your Plugin, otherwise it would cause the same files to be loaded twice. This means that if you want to ship an Engine as gem it cannot be used as plugin and vice-versa." Can anyone be more specific a...

Social Networking Style Notifications System in Rails

Hi, I am building a social network from the ground up in rails and I am wanting to set up a face-book style notification system for displaying new messages, friend requests, etc... in a visual appealing and UI friendly manner. What's the best way to go about this? I am thinking of using acts_as_state_machine but it seems a bit out of da...

Keep selected value in collection_select as active after submit

Dear All, View <form align="center" name="gm" action=""> <label for="col1"><b>Name: </b></label> <%= collection_select(@table, "gm", @pop1, "col1", "col1", :prompt => true) %> <%= submit_tag value="Proceed-->"%> <form name="sp" action=""> <label for="col2"><b>Class: </b></label> <%= collection_select(@table, "sp", @pop2, "col...