ruby-on-rails

Active Directory - Django/Rails

I'm thinking about re-writing a web app in Django or Rails and wondering about authenticating against AD. Is one ecosystem better suited for this (libraries, etc) or is it a toss-up? (The app will be hosted on Linux) I have lots of reasons for the re-write, one them is to make myself more marketable. Anyone care to comment on the whic...

Ruby on Rails: Error when running a rake task from initializer file

I have the file config/initializers/custom.rb In the file, there is only one line: `rake thinking_sphinx:start` I thought this was supposed to just execute the line like when typing it from a command line. With this line of code, when I run "ruby script/server", the server freezes and outputs no error messages. Am I missing somethi...

How do websites use hitcounters to drive traffic

I am looking for a way to keep track of the number of hits to a particular webpage. When the number of hits reaches a certain number traffic is driven to a different web page. Specifically I could use this to mod the number of hits by different values and drive people to different webpages on this logic. Do free web traffic analytics sof...

Using Javascript OpenID Selector with Rails

Based on this article, it seems like SO is using Javascript OpenID Selector (JOIS) to handle OpenID logins in its "view". I love the simple interface and I would like to use it in a Rails project. I know that RPX would probably be the easier choice, but I'd like to build this on my own. Can you help me find answers to a few question...

Turning off json key quoting in Rails

One of the features in Rails 2.3 was json key quoting. I was wondering if there was an easy way to turn the key quoting off or modify the way quoting is done (change to single quotes for example). I'd like to output a json format that Google's Visualization API will accept (http://code.google.com/apis/visualization/documentation/dev/im...

Data model for a private messaging system

I am writing a private messaging system for my web app. Just think of it as doing the same thing as sending PMs on your typical social networking website like Facebook or Twitter, or even sending an e-mail through Hotmail. I have come up with the following migration so far: class CreateMessages < ActiveRecord::Migration def self.up ...

size limit of a mysql query ruby/mysql

Hello everyone, I hope this is the appropriate place to ask my question. My mysql query currently looks like this @records = Record.find(:all, :select => "`records`.id, records.level as level, (SELECT (count( b.id ) + 1) FROM records as a, records as b WHERE a.id = records.id and b.skill > a.skill and b.created_at ='#{vandaag}' ...

Passenger crash when trying to use https

Hello, I am using the ssl_requirements plugin on shared hosting account. This hosting provider uses Passenger to manage Rails. Everything works fine until I try to go to a page that requires ssl (enforced by adding the ssl_required filter). When this happens Passenger crashes and sends back a 500 error. The error reads: Passenger encou...

Automatic associations in ruby on rails fixtures

As described in this article, I am using automatic associations in fixtures. For example, if a region object has a country id, instead of doing "country_id": 1, I do "country": "USA". "USA" is a label in my countries.yml file, so fixtures knows how to take care of this. However, this only works when you do not specify an ID value for ...

how can I pass a value between controllers (new -> create) in RoR

This may seem basic but I can't figure it out. I have a "Write Review" link which looks as follows: <%= link_to 'Write', new_review_path(@new, :vendor_id => @vendor.id) %> This creates the URL: reviews/new?vendor_id=10 All I want is to create a new Review object based on three inputs: vendor_id (above) user_id (which is working c...

Restful Rails "perspectives"?

Say I want to render a page that isn't necessarily tied to a model. Up until now I have been creating a controller titled, "Pages", and a route for each page: map.home :controller => "pages", :action => "home" This isn't restful and it is tedious. Surely there is a better way to handle "perspectives" such as this? Note: I avoid the t...

ActiveRecord does not work on App Engine - What's the alternative?

Early reports of JRuby on Google App Engine indicate that ActiveRecord does not work. It was my understanding that this was the only way to talk to the database in Rails. Is this not the case? And, if not, what is the alternative? Is there a more direct way in Rails of interfacing with Google's BigTable datastore? ...

Ruby on Rails: How to join two tables

I have an index page that I want to show all the users' profile and their associated photos. I'm using the plugin Paperclip for the photos. In the Profiles controller, I have the instance variable @profile but it shows me the table in the profiles table only and not the photos table. @profile = Profile.find(:all, :include => :photos, ...

Ruby on Rails and Security

Has anyone ran across any good Powerpoint presentations on how to securely develop a web application in Ruby? ...

How to configure Ruby on Rails with Oracle?

There's several pages on the net that discuss this, but most are out of date or inaccurate in some what. What's the scoop? ...

how to display vendor_id for my reviews by a given user?

I am trying to write a simple application and I am stumped! Here is what I have as a view for users/show/1: <p> <b>User:</b> <%=h @user.login %> </p> <% if @user.reviews.empty? %> No Analyst Reports yet <% else %> <% for review in @user.reviews %> <%= review.vendor_id %><%= review.summary %><br /> <hr...

What is the best Rails caching option for largely static pages with a dynamic header

I have a set of largely static pages which I'd be happy to page cache for relatively long periods apart from the fact that their layout includes a much more dynamic header. The most promising idea so far seems to be using action caching without layout :- class SomethingController < ApplicationController caches_action :index, :layout...

Is it legal to stub the #class method of a Mock object when using RSpec in a Ruby on Rails application?

I would like to stub the #class method of a mock object: describe Letter do before(:each) do @john = mock("John") @john.stub!(:id).and_return(5) @john.stub!(:class).and_return(Person) # is this ok? @john.stub!(:name).and_return("John F.") Person.stub!(:find).and_return(@john) end it.should "have a valid #to fi...

Mixing security logic with models in Ruby on Rails?

Is it bad design to mix code that deals with security logic in the model? Example for editing a page in the before_save callback The current user is grabbed from the current_user method in the Controller layer. Throw exception if current_user.has_permission? :edit_page is false The editor_id is set to current_user.id The change is log...

Destroy associations after the last has_many :through record is deleted

With a regular has_many, there's the option of :dependent => :destroy to delete the associations when the parent record is deleted. With has_many :through, there might be other parents associated to the child records, so :dependent => :destroy doesn't have any effect. How do you ensure child records are deleted after they are orphaned f...