ruby-on-rails

User management using sinatra

Hi, I need to make a basic user management system for my application using Sinatra but I'm not sure how I should think about it. It needs to: Register User Login User How should I think about it? This shouldn't be hard, I'm just very new to all this. Thank you. ...

Should I use ruby 1.9.2 when starting a new Rails 3.0 project?

App will run on Heroku Dependencies include paperclip haml compass devise aws-s3 Reasons for or against? Any recommendation on another version of ruby? Update Heroku currently doesn't support 1.9.2 but it's expected to very soon based on this post. Rails 3.0 officially supports 1.9.2 (but not 1.9.1), so I decided to go ahead and ...

rails log issue

how do i fix this issue and get it to stop happening CONFLICT (delete/modify): log/development.log deleted in eccc398bb3058c5c0cc9e3587aae93289597fc0f and modified in HEAD. Version HEAD of log/development.log left in tree. I have it in .gitignore ...

Ordering results by relevance using Solr search

I'm new to Solr search and trying to get a grasp on how to handle ordering of results. I'm using Ruby on Rails together with the Sunspot gem to interface with Solr. I have an Article model, that has the following fields that are indexed: text Title text AuthorNames integer NumberOfReviews I'd like to be able to perform a search on So...

How I get the Railscasts episode "#229: Polling for Changes" to work with a nested route?

I have a rails 3 application very similar to the one in Railscasts episode #229 the only difference is that in my code Articles is called Posts and I have a nested route: routes.rb: Myapp::Application.routes.draw do resources :posts do resources :comments end root :to => "tags#index" end I receive this error in the terminal...

Boson vs Thor for console applications

Has anyone used both: Boson: http://tagaholic.me/2009/10/14/boson-command-your-ruby-universe.html and Thor: http://github.com/wycats/thor Thor are very popular and have more followers and contributers than Boson, but Boson looks far more powerful than Thor and the architecture is very well thought out. In Boson you: can add method...

Rails App using Selenium but NOT for Testing -- How to organize ?

I am creating a rails app that is meant to be run locally and automate some of my web based tasks. The reason for rails is that I will import data in, select a number of tasks to be completed, then tell it to start. Ideally i will keep logs of runs and keep track of what tasks were completed during specific runs. My experience with...

Pros/Cons of storing serialized hash vs. key/value database object in ActiveRecord?

If I have several objects that each have basically a Profile, what I'm using to store random attributes, what are the pros and cons of: Storing a serialized hash in a column for a record, vs. Storing a bunch of key/value objects that belong_to the main object. Code Say you have STI records like these: class Building < ActiveRecord:...

Would Rails' number_to_human(0) giving an error be a bug?

All of the following works well in rails console (Rails 3) except for 0... wouldn't the human readable form of 0 just be 0? irb(main):015:0> helper.number_to_human 1 => "1" irb(main):016:0> helper.number_to_human 2 => "2" irb(main):017:0> helper.number_to_human 200 => "200" irb(main):018:0> helper.number_to_human 3000 => "3 Thousand" ir...

Ruby/Rails constant behavior

I am new to Ruby (coming from java background) and I was wondering whats the behavior for constants in RoR applications and in general Ruby. Are they just initialized once, like java static variables? I am initializing a fairly big array of hash as a constant, so I want to be sure if I am doing it right? Thanks for your help. module...

Rails 3 Cookie Based Sessions Question

With Rails 3, the default session storage mechanism is cookie_store. I assume that this means that the contents within the session hash are serialized, encoded and stored within a cookie in the browser? Does this mean that nothing (or very little) of the session is stored in the server? I've had a few issues where I had a cookie overflo...

Area chart with multiple Y-values in a single interval on X-axis.

I am using Highcharts to make area charts for certain data for a day. The data is collected every 15 mins and the data is shown for one day where the X-axis interval is 2 hours. So for every interval I have 8 points which are to be used to construct the area chart. What I guessed was that if I give plotOptions as plotOptions: { ...

will_paginate ajax pagination with thinking sphinx

Has anyone ever tried paginating a thinking sphinx result set thru ajax? I have this is in my controller action: @results = Model.search params[:query], :page => params[:page] || 1, :per_page => 1 and in my application.js: $(".pagination a").live("click", function() { $.get(this.href, null, null, "script"); return false; });...

gem --version different to sudo gem --version :(

I'm a bit of a Linux noob trying to get ruby, rails, mysql and sqlite all playing nicely on ubuntu 10. I am getting errors, and I realized that the versions are different for sudo versus normal user! mpw@ubuntu:~/.rvm/gems/ruby-1.9.2-p0$ gem --version 1.3.7 mpw@ubuntu:~/.rvm/gems/ruby-1.9.2-p0$ sudo gem --version 1.3.5 I have used RVM...

about rails' routes, adding collection routes to restful resources won't generate named route helpers ?

namespace :admin do resources :posts do collection do get 'whatever' end end end I was expect that will generate 'whatever_admin_posts_path' helper method, but it didn't. It's there something wrong with my codes? Or a bug in rails? ...

Using Authlogic to authenticate with only a username

There's this mother app which is on Java (Struts), which also handles authentication. My Rails app which is being integrated into the mother app uses authlogic. Ofcourse, the requirement is, once someone logs into the mother app, they should automatically be able to access my Rails app without signing in again. Is there any way, by usin...

easy shortcut for <%= in vim (for rails apps)

I type <%= often enough in rails that I want to find a shortcut for it. I am looking for a VIM solution (I specifically use macVim) I know I can map it to keys or create my own snippetMate.vim snippet but I'm wondering if there's a generally accepted way of doing this. ...

I am trying to run rails on Apache, but can't get it into development mode

Hi there, I am setting up a development environment for ruby on rails. Using rails 3.0, ubuntu, mysql and apache2 with passenger. So far so good until I go to localhost and it tells me: "Mysql2::Error Unknown database '[app-name]_production'" The error occurs because I don't have a production database. Only _development and _test. ...

Clearing a text field if nothing is submitted

I don't know if this is even possible, but in my rails app, I have this currently to put text in a text_field to be a description instead of having an external label: <% inside = "Search for Customers" %> <%= text_field_tag :search, params[:search], :style => "color:#aaa;", :...

Resolved : How to add the java variable value in the Configuration util String -

Hi , I am writing Java code for calling ROR APIs .. I have written Java code to get all the blogs by public List<BlogBean> getBlogsXml() { return webResource.path(ConfigurationUtil.LIST_BLOGS).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication) .accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<Lis...