ruby-on-rails

In Rails, why sqlite works without config.gem 'sqlite3-ruby'

With a new Rails 2.3.10 project, the file config/environment.rb has the following line commented out: # config.gem "sqlite3-ruby", :lib => "sqlite3" but for some reason, I tried a scaffold foo, and start the rails server, and the app is running. I thought the requirement is, every gem the app needs, it has to be listed in config/en...

For Rails, "rake doc:guides" generate Rails Guide for 2.2.2 and 3.0.1 but not 2.3.8 or 2.3.10?

I didn't know that the old Rails guide is available by cd railsproject_folder rake doc:guides cd doc/guides and since our project has been using Rails 2.2.2, so the Rails guides for Rails 2.2.2 can be seen there, because the official Rails guide on web is for Rail 3.0. I tried that with Rails 3.0.1, and it works too. With Rails 2.2....

Using a Nested-Model form as a Partial on a different models's page

Hello, I have a nested model form for PhotoAlbums. The form works fine via the standard html. But what I need to do is render it as a partial in another page it's erroring: "No route matches {:action=>"create", :controller=>"photo_albums"}" The models: Projects has_many :photo_albums PhotoAlbums belongs_to :project has_m...

Is there a cleaner way to write this? (Ruby/Rails blocks, return value)

def find_users_online(count = 1) users = Array.new count.times do users += get_users_online end users # <==== I want to remove this here end In the code above im must put the "users" variable again at the end of the function to return the right value (users). But is it possible that the times block ...

What is need to build native extension for Gems on Windows? (RubyGems)

More and more gems I run into requires building "native extensive", such as RedCloth. Are there tools that are open-source or free that is sufficient to do that? I heard MS Visual Studio also has a free version. Will that be enough to build native extensions? ...

Increase scan rate autotest with rspec

I find the integration with RSpec, Growl and rails particularly useful. However, it takes about two to three seconds before a change (save file) is picked up by autotest. Is there a way to increase the interval by which autotest scans for filechanges? ...

Rails 3, HTTP extensions (WebDAV) and Rack App mounting

Hello, 1 The following is more to point out to the code devs an issue of rails that can be percieved as a flaw. 2 And also me asking some oppinions from people who know better. I want to add WebDAV to my Rails 3 App with Warden authentication. My warden middleware is injected via Devise. http://github.com/chrisroberts/dav4rack ...

Is it possible in Rails3, to have a multipart form => true & use remote => true

I'm using the following form tag for @jobs which have job_photos included. <% form_for @jobs, :html => { :multipart => true }, :remote => true do |f| %> The form works fine non-remote, but if I add the remote = > true, the form submits, returns create.js but doesn't save anything to the DB or error? ...

Database strategy for over 10,000 instances of an ERP

Hi , I have a moderately large rails ERP application having around 80 tables . I use MySQL . I recently received a client requirement which needs me to deploy the same application for roughly 10,000 offices(an instance for each office). The central office(superadmin office) must be able to view details from all these offices . After tal...

Override a scope in rails 3

I want to override an existing scope to add an extra condition to it. I've shown my attempt to do this using alias_method. Unfortunately this approach doesn't work with scopes, I get an undefined method error. How do I do it with scopes? module Delayed module Backend module ActiveRecord class Job < ::ActiveRecord::Base ...

Installing MYSQL and passenger gems, getting no definitions for documentation

I'm running Mac OSX 10.6.4 and setting up rails for the first time. I've been following a bunch of guides to get set up, specifically these two here and here. Also, I know this question has been asked before, but nothing has helped me and my circumstances are a bit different. First, let me give you my setup. I've installed Xcode, ...

Can a 3-way relationship be modeled this way in Rails?

A User can have many roles, but only one role per Brand. Class User < AR::Base has_and_belongs_to_many :roles, :join_table => "user_brand_roles" has_and_belongs_to_many :brands, :join_table => "user_brand_roles" end The problem with this setup is, how do I check the brand and the role at the same time? Or would I better off w...

Thinking Sphinx Rebuild, then whenever saving any page it does save, but return error.

I did a rake thinking_sphinx:rebuild, then when I try to update any page/entry, it does save but it returns error. New data is saved, but the page returns error. What have I done wrong? Before I did the above command, things were working fine. I had to issue that command because I did some changes on the sorting filter. ...

Rails 3 with Uploadify & Paper_Clip

Anyone here haveRails 3 with Uploadify & Paper_Clip experience? I'd like to allow the user to upload photos: Here is my view: <input id="fileInput" name="fileInput" type="file" /> <script type="text/javascript"> $(document).ready(function() { $('#fileInput').uploadify({ uploader : '/uploadify/u...

inherited_resources and cancan conflict

Hi, There are conflict with inherited_resources and Ryan Bates's cancan gem. I have some simple controller class IssuesController < InheritedResources::Base respond_to :html load_and_authorize_resource def tag @issues = Issue.tagged_with(params[:tag]).recent.paginate(:page => params[:page]) end protected def collec...

Merge of 2 active record arrays very slow?

I have 2 sets of data as following: default_products - A set of active record objects retrieved from memcached owned_products - A set of active record objects retrieved from the database Retrieving the data is fast and i get around 30-40 req/s when just returning either one of the arrays yet as soon as i do the following to return both...

Ruby on Rails Image Upload/Text Overlay

I'm new to using ruby on rails and was looking for help with image upload/manipulation. The extend of my RoR experience is the rails tutorial blog project, but I've used Java and PHP for numerous other projects. I'm trying to create a simple app where the user uploads a file, enters some text, and the text is overlayed on the supplied ...

Strange behavior between rails and irb

If I drop in to irb and do require 'atom' I can successfully include the gem but if I try to include it in my controller in rails I get no such file to load -- atom when I visit the page in the browser. What's going on here? Here's the complete stack trace: C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_r...

Changing the first day of week in rails

I and trying to build a calendar in ruby on rails. In ruby-on-rails, monday is considered to be the first day of the week, but i have to set sunday as the first. I intend to change this to properly use the date's built-in methods RoR. Assuming today is sunday, oct 24th. Look the example: Date.now.beginning_of_week it prints: 2010-10-...

How to save Rails log to database outside the application?

I'm trying to save the Production environment log to the database on other server.. What I mean that when some errors shown I want to open ssh and check the end of production.log.. What I want is to go to the other database (on other server maybe) ant check it out. I want the logged information to be the same as I see in the *.log, cont...