ruby-on-rails

rails link_to :remote from within ajax-loaded content

Hey everyone, I'm working on an application and I'm having difficulty with the new Rails 3 link_to. Here's the situation - I have two divs on my "home" page, and each div is populated at document.load with ajax. This works as expected. In the content of the pages I'm loading into these divs, I want to use the link_to... :remote => true ...

HAML's eating the white space can be "%span><=", but not "><="?

I have used %span><= and it can eat up the white space between this line and the next, and also outside of the span tag, but it seems like an element needs to be used. The form ><= or <= or >= can't be used to eat the space. Or is there some ways to make them work? some docs at: http://haml-lang.com/docs/yardoc/file.HA...

Rails - Making @projects avaialble on all page loads

Hello, On every page of my app I want to show a user's projects... So which controller do I use to make sure that @projects from the projects controller is being made available in the view? Thanks ...

RoR web tier with Java middle/backend

I'm looking for some advice/feedback about using different languages in a layered architecture. Right now the architecture in question is an all java stack (db, middle tier, and web tier) using Spring to tie everything together. We've been tossing around the idea of using Ruby on Rails for the web tier, but I'd like to know if anyone has...

Javascript Hover Content Show

Hello, I am attempting to write a JS function (using prototype in rails) that will show hidden divs within a li when that li is mouseover'ed. Each li has a unique id that is a number, like so: <li id="100"> <div style="display:none;" id="hover-display-content">Content</div> <div style="display:none;" id="more-hover-display-content"...

ruby active_record primary key retrieval/custom primary key update

I'm working on a legacy database system where the primary key, for some strange reason, starts with 1 and is not set to AUTO INCREMENT and the next value is always max primary key + 1 (the primary key is still an integer). Furthermore, the primary key names are all custom and set by set_primary_key. Now I want to map ActiveRecord to it ...

Rails: link_to with :remote => true not working

I'm trying to implement a voting system kind of like the one here on Stack Overflow. (Using Rails 3) I want the voting to be done without a page reload, so I have this code link_to("/tags/#{tag.id}/upVote", :remote => true ) And so in my /views/tags directory I have a file called _upVote.js.erb that I thought would be called when this...

Wrapping if-else statement in content_tag for Rails

How do I wrap if-else statement in a content_tag? def entry_template content_tag(:div, :class => "item_title") do "<h3> if x == 'garage' #{entry.garage.name} else 'Not garage' end </h3>" end end Thanks! ...

Rails - Passing an option variable in a partial

Hello, I'm building a header partial for a view. I call the partial as following: <%= render :partial =>"project/header", :locals => {:right_header => 'BLAH BLAH'} %> The header has a default right_header, but I'd like the option to overwrite it: <div id="header"> <span class="right"> Standard Header here </span> </div> The deal i...

gem_original_require: no such file to load -- spec/rails

Hi All, I have a rails 2.3.8 app with rspec tests (not written by me, just trying to get them running). When I run "rake spec" I get this error: gem_original_require': no such file to load -- spec/rails (MissingSourceFile) I have the following rspec-related gems installed: rails (2.3.8, 2.3.5) rspec (2.0.1, 1.3.0, 1.2.9, 1.2.4) rsp...

save image from url by paperclip

please suggest me a way save image from url by paperclip. thanks ...

Direct downloading a xls file without writing it to the directory by Spreadsheet gem

I am using this Spreadsheet gem to export xls file. I have the following codes in my controller: def export @data = Data.all book = Spreadsheet::Workbook.new sheet = book.create_worksheet :name => "data" contruct_body(sheet, @data) book.write "data.xls" end In this way, I can fill in the data and save it in the root dire...

How to access validation messages in partials?

So, each rails project i seem to run into this problem and would be really grateful if someone could enlighten me: With a "normal" setup when the form sits on the view immediately associated with the url/controller it is pretty straightforward, a render => :action on fail will display the validation message. Now what i have is a form i...

in rails is there some object has nil!

i know there some object has nil? method,i want to know is there some method with nil!? ...

Setting up Apache for Rails production. Please help!

Hello! I am developing a Rails 3 application and I have installed Capistrano on the client side and Passenger with Apache 2 on the server side. I make a deployment and the files are sent to a folder called u/apps/. But when I visit the IP address I am currently using I only get to an empty folder, how do I configure apache to look for...

Unable to install plugin in Rails

I'm running Windows 7 32 bit. I just installed Ruby 1.9.2 and Rails 3.0.1. I set up my rails sample application and everything seems to be working fine. I tried installing the restful_authentication plugin from github and it's been a nightmare. I'm executing the following command: rails plugin install -force git://github.com/technoweeni...

I've been using Authlogic, but now need to remove all traces of it. What do I need to do?

So I'm going to switch from Authlogic to Devise. Since I only have a couple of test accounts, I thought it would be best to simply remove all the Authlogic stuff and my users table, then setup Devise. I'm using Rails 3. Apart from removing authlogic from my gemfile, removing the user and user_session models/tables, is there anything else...

Post request by ruby code and JAva code for Rails application

Hi, i am trying to call my Rails app using Ruby code . I m having 2 tables . Blogposts (id,name,slug,desc) Comments (id,data,node_id,node_type) I m trying to post a comment through my ruby code. The Url for me is like http://localhost:3000/api/blogs/comment.xml?slug=blogtitle-0&amp;comment=aaaaaaaaaaaaaaa I dont know how to write ...

What is the equivalent of script/destroy scaffold User in Rails 3?

When I was using Rails 2, I did script/generate scaffold User to create the user model. Now I need to remove it, and I'm using Rails 3. I tried rails destroy scaffold User and rails destroy User, but these just created new rails projects named destroy. How do I do it? Thanks for reading. ...

Rails times oddness : "x days from now"

Hi all. when users sign up to one of my sites for a free trial, i set their account expiry to be "14.days.from_now". Then on the home page i show how many days they have remaining, which i get with: (user.trial_expires - Time.now)/86400 (because there are 86400 seconds in a day, ie 60 * 60 * 24) The funny thing is, this comes out ...