ruby-on-rails

activerecord rails find pages who have no groups

Hi guys.. I have a the following situation: pages has many groups. Now i am trying to find the first page who hasn't got a group with activerecord. I tried things like this: Page.find(:first, :joins => :groups, :select => 'DISTINCT `pages`.*') but of course no luck so far. ...

How do I run rake tasks within my rails application.

What I want to do: In a model.rb, in after_commit, I want to run rake task ts:reindex ts:reindex is normally run with a rake ts:index ...

problems installing sqlite3-rubygem and mysql

I have recently updated my mac to snow leopard and am having a terrible time configuring it for rails development. I have followed the tutorial at hivelogic (http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard) and am being returned with the following error. I have also attempted to install sqlite3-ruby gem an...

How can I assign event handler to page objects using ajax and UJS

Hi all! Can someone please advise a good approach to this problem: On page load, an event handler is added to a page element. For example: // Javascript // when page is loaded... jQuery(document).ready(function) { // assign this handler to the buttonDiv element... jQuery("#buttonDiv").click(function() { // to alert "hello" ...

Redirecting www to non www on server with wildcard subdomains

Hi, I have a Rails+Apache+Passenger setup and my app serves wildcard subdomains. I need all www URLs to redirect to their non www equivalents. www.example.net should redirect to example.net www.subdomain.example.net should redirect to subdomain.example.net My current vhost config is as below <VirtualHost *:80> ServerName exampl...

:include rails mutliple sql statement RAILS

Hi Guys I just asked a question about this.. But i now have another question i can't figure out :( So i have a many_to_many relationship pages has many groups and groups has many pages. Page.all( :include => :groups,           :conditions => ["#{Group.table_name}.id IS NULL AND client_id='#{session[:client_id]}' AND parent_id IS NUL...

NSURLConnection cache clearing and reconnecting problem problem

Hi, Given a rails application which communicates with my ipad app. I'm using async connection with http authentication. And i would like to test the credentials if they are ok. The problem is that if i enter the good credentials and after that i'm changing to a wrong one, the connection still accepts. Only refuses when I reopen the appl...

How can I use a SOAP API in my Rails app in Heroku and EngineYard?

Hi, I've got a pure, working, Rails application hosted on Heroku and another on EngineYard. I now need it to start communicating with another application. This application exposes that exposes a SOAP interface. How can I connect to the API in my rails app? Thank you ...

Ruby on Rails .htaccess issue

When I run newly created Rails application on Apache, I can only access it's default front page ( standard app/public/index.html) file. When I try to run custom method via URI I get page not found. So I'm guessing that something is wrong with my .htaccess. Do I have to "open" it for every controller? RewriteCond %{HTTP_HOST} ^example.c...

rails ajax requested form has wrong method

Hello, I have a _form.html.erb partial that comes from the standard rails 3 template for the model project. #view: <div id="content"> <%= link_to 'Edit', edit_project_path(@project), :remote => :true %> </div> #projects controllers def edit @project = Project.find(params[:id]) respond_to do |f...

Creating a named_scope for "no children" in a has_many association

I would like to have a named_scope for blogs with zero posts. The following does not work. class Post < ActiveRecord::Base belongs_to :blog end class Blog < ActiveRecord::Base has_many :posts named_scope :has_no_posts, :conditions => "blogs.id NOT IN (SELECT blog_id FROM posts)" end ...

How to stop with debugger on NoMethodError in NetBeans when running Ruby?

Netbeans 6.9 JRuby 1.5.0 rails 2.3.4 Error example: NoMethodError in Report#week Showing app/views/report/_list_record.html.erb where line #26 raised: You have a nil object when you didn't expect it! The error occurred while evaluating nil.sorting .... I can set up breakpoints, the debugger works fine. But when I have a NoSuch...

Belongs_to based on value of a field

Hello, I have a table with entries, and each entries can have different account-types. I'm trying to define and return the account based on the value of cindof Each account type has one table, account_site and account_page. So a regular belongs_to won't do. So is there any way to return something like: belongs_to :account, :class_nam...

push Rails3 on Heroku. can not find mysql gem

hi, i'm getting an error when pushing to heroku using rails 3. I'm on windows with ruby 1.8.7 Administrator@WIN-DQC3IH63U7C ~/nasha (master) $ heroku rake db:migrate rake aborted! no such file to load -- mysql /disk1/home/slugs/280561_9c64ba2_1741/mnt/Rakefile:4 (See full trace by running task with --trace) (in /disk1/home/slugs/280561_...

How do I map unique values from a multi-level array to a hash of value=>array?

I have an array that looks something like this: [[100, "one"], [101, "one"], [102, "one"], [103, "two"], [104, "three"], [105, "three"]] What I would like to do is create an array of hashes that looks like this [{"one" => [100,101,102]}, {"two" => [103]}, {"three" => [104,105]}] The number portion will always be unique, the ...

Good field names that work for both Rails and .Net apps

I'm really thinking that in the years ahead, I will be creating internal apps in both Rails and .Net Entity Framework that will need to work nicely again the same SQL Server or MySql database tables. At this point I'm pretty much greenfield in the table designs, so I can name my columns anything I want to. I've studied Rails and .Net E...

shoulda should "be valid" do fails with "'handle_matcher': undefined method 'matches?'"

I'm trying out 'shoulda' on top of rspec (rails 3) with the following spec: require 'spec_helper' describe Article do should "be true" do assert true end end and it fails with /Users/jeppe/.rvm/gems/ruby-1.8.7-p302/gems/rspec-expectations-2.0.0.beta.20/lib/rspec/expectations/handler.rb:11:in `handle_matcher': undefined method...

Docmail API for ROR application for postcard

Hi, I am using docmail's Simple API for sending Postcard.They have implemented this functionality recently, but I didn't get any sample code or instruction for implementation. Thanks in advance, Gaurav Soni ...

Distinguishing between nginx and thin

This is a newbie question around nginx and thin in the rails environment. In reading/learning on rails I frequently hear about nginx and thin being a great combination for a rails site. In reading the descriptions of each, they both describe themselves as web servers, so I'm a little confused at what the combination brings to the tabl...

how to display current date in mm/dd/yyyy format in rails

In my view i want to diplay current date in mm/dd/yyyy format ...