ruby-on-rails

Is Ruby on Rails slow with medium traffic?

Hello ! I made some searches on Google, and I read some posts, articles and benchmarks about Ruby on Rails being slow and I am planning to build one website that will have a good amount of users inserting data and there will be some applications to process this data (maybe in Ruby, you can help me choosing the language). What is the r...

How can I do a right outer join in a Rails controller?

In a Rails controller, I'm setting a variable like this: @users = User.find(:all, :joins => family) This gives me all the users that have families. What I want is exactly the opposite: all the users that don't have families. I tried adding: :conditions=> {:family => nil} ... but got an error. What's the proper way to do a right o...

Regular expression too big error for cucumber pickle

I am getting below error when i am trying to run my cucumber features. Using the default profile... WARNING: Nokogiri was built against LibXML version 2.7.5, but has dynamically loaded 2.7.6 Strategy is : truncation and ORM is active_record regular expression too big: /^((?:(?:)|(?:(?:a|an|another|the|that) )?(?:(?:(?:(?:first|last|...

Why can't I set boolean columns with update?

I'm making a user administration page. For the system I'm creating, users need to be approved. Sometimes, there will be many users to approve, so I'd like to make that easy. I'm storing this as a boolean column called approved. I remembered the Edit Multiple Individually Railscast and thought it would be a great fit. However, I'm ru...

Designing template for Ruby on Rails view. What and where to learn?

Hi. I have a project going on, and I am in charge of the front-end design, whereas my developers will work on the back-end with Ruby on Rails. I do not know Ruby on Rails, and am designing front-end using XHTML, CSS, jQuery, 960.gs CSS Framework. My developer is supposed to take my design and connect the elements of back-end to it, with...

How to make a small engine like Wolfram|Alpha?

Lets say I have three models/tables: operating_systems, words, and programming_languages: # operating_systems name:string created_by:string family:string Windows Microsoft MS-DOS Mac OS X Apple UNIX Linux Linus Torvalds UNIX UNIX AT&T UNIX # words word:string defenitions:string wi...

Removing "duplicate objects"

Let's say I have an array of objects from the same class, with two attributes of concern here: name and created_at. How do I find objects with the same name (considered dups) in the array, and then delete the duplicate record in the database. The object with the most-recent created_at date, however, is the one that must be deleted. ...

form_form and custom parameter in path_prefix

Hi people, I have this route: # config/routes.rb map.namespace :backshop, :path_prefix => '/:shop_id/admin' do |backshop| backshop.resources :items end And I want to use the form_for magic to reuse the same form on both: new and edit views: <% form_for [:backshop, @item] do |f| %> This used to works, and used to build a create ...

How to stop auto encoding of <%= strings %> with Rails 3.0beta

I'm using rails 3.0beta3. In my index.html.erb and in my index.js.erb, if I have: <%= "string with unsafe characters' like <" %> It will automatically be encoded to: string with unsafe characters&quot; like &amp; just the same as if I had used: <%=h "string with unsafe characters' like <" %> How do I get it to stop? I have stor...

How to know if model is used from Rake ?

Hi In a model, I include a module used by a Rake task. I would like to do this include only for rake and not for Rails. I didn't find any method to know if the model is used by Rails or Rake. I use Rails3.0.beta3. If you have any idea i would be glad to hear them :) Thanks ...

Rails: unable to set any attribute of child model

I'm having a problem instantiating a ListItem object with specified attributes. For some reason all attributes are set to nil even if I specify values. However, if I specify attributes for a List, they retain their values. Attributes for a List retain their values: >> list = List.new(:id => 20, :name => "Test List") => #<List id: 20, n...

Faster RSpec with JRuby

Hello, I'm pretty new to the whole JRuby world. I'm using RSpec on a pretty big test suite. I'd like to be able to run the specs frequently but the JVM takes so long to startup it's becoming a real time drain. Is there a way to keep the JVM running? or a way to get specs to run faster with JRuby? Thanks in advance for the help, JPoz ...

rake test and test_structure.sql

First of all, I have to run "rake RAILS_ENV=test ..." to get the test suites to hit my test DB. Annoying but ok to live with. However when I do so, I get a long stream of errors like so: > rake RAILS_ENV=test -I test test:units psql:/path/to/project/db/test_structure.sql:33: ERROR: function "armor" already exists with same argument ty...

How Do I Search Between a Date Range, Using the ActiveRecord Model?

I am new to both Ruby and ActiveRecord. I currently have a need to modify and existing piece of code to add a date range in the select. The current piece goes like this: ReportsThirdparty.find(:all, :conditions => {:site_id=>site_id, :campaign_id=>campaign_id, :size_id=>size_id}) Now, I need to add a range, but I am not sure how to d...

Rails application information

I want to store some information about my rails application, like a version number. I am new to rails and I'm sure there is some sort of convention for doing this. What is the best method of doing this, maybe the environments file? ...

Rails partial show latest 5 kases

Hi Everyone, I have my application setup with a few different partials working well. I have asked here how to get a partial working to show the latest entry in the kase model, but now I need to show the latest 5 entries in the kase model in a partial. I have duplicated the show most recent one partial and it's working where I need it ...

What database to use with Ruby on Rails, based on actual Hosting services ?

Hello ! I've been looking for hosting services and I still don't know what kind of database is the most commom. It seems to be MySql and PostgreSql. So, I'm not sure about how much traffic and data my website will have (it's just a project), but I would like to be prepared. I've worked in some projects with Oracle (PL/SQL) and I know s...

Ruby on Rails - Calendar Display

We want to create a calendar view in a room scheduling application. The outcome we want is to have hours open (variable depending on day) across the top of the grid and the names of the rooms down the left side of the grid. The body would be populated with bookings for that day. The visual we're seeking is similar to the "Weekly Build...

Pass a variable from view to the layout's partial view

I am trying using a partial to render the application's menu, capitalizing the 'tab' using CSS, based on a local variable (tab): <%= link_to "employees", jobs_path, :class => (tab=="employees" ? "selected":"unselected") %> <a class="unselected">jobs</a> <%= link_to "tags", tags_path, :class => (tab=="tags" ? "selected":"unselected...

Ruby complex validation

Have a product that belongs to a category. Want to create a promotion for a short period of time (lets say a week or two), but their can be only one promotion per category during that time. How can I create a custom validation for this? product class belongs_to :categories name:string desc:text reg_price:decimal categor...