ruby-on-rails

Phusion Passenger Configuration via .htaccess

I'm trying to install Redmine, and I am having trouble making Phusion Passenger work with any directories other than the DocumentRoot. I've put the public directory downloaded from Redmine into ~/www/public/entry/redmine.mysite.com/, and the rest of the directories in ~/www/app/redmine.mysite.com/. I've added the following line to the ...

Is there a way to list the available variables in an Ruby ERB template?

Hi All, Suppose I have a Ruby ERB template named my_template.html.erb, and it contains the following: <div><%= @div_1 %></div> <div><%= @div_2 %></div> <div><%= @div_3 %></div> Is there a way I can programatically list out all the available variables in the template? For example, the following method: def list_out_variables templ...

Missing PID file when using a process manager to start delayed job

I am using BluePill to manage processes such as delayed job for Rails. In the BluePill log, I am getting this message: W, [2010-09-27T01:23:20.447053 #19441] WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read W, [2010-09-27T01:23:20.447368 #19441] WARN -- : [fsg_di...

Ruby on Rails Base URI

I am using Phusion Passenger to host a rails app on an Apache server (I am very new to rails). I have several domain names that point to the same server, and a mod_rewrite is used to direct different domains to different subdirectories. I was having a difficult time getting the app to load at all, but I set RailsBaseURI to the path rel...

Rails 3 Form?, has a TextArea and Rails gives it an ID, but I'll have several on a page

Hello, here is my partial for writing a comment: <div class="commentBox"> <%=form_for [commentable,Comment.new], :remote => true do |f|%> <%=f.text_area :content, :placeholder=>"Write a comment...", :title=>"Write a comment..." %> <%=f.hidden_field :parent_id%> <br /> <%=f.submit "Add comment"%> <...

Rails 3 - How to Link to a User given a user_id

I'm outputting comments on a /books/1 I have the following: <%= comment.user.id%> ---- This gives the correct user_id What I want to do is create: <%= link_to comment.user.fname, XXXXXXXXXXXXXX %> What I don't know what to put for XXXXXXXXXXXXXX that links to /users/1 1 being the id from the comment.user.id Ideas? ...

140 Characters, is that a string or text?

Hey guys, just doing a quick scaffold on rails, and I'm going to have a field that's only 140 characters or less, is that a string or text? ...

Trying to learn RoR, but keep getting Page doesn't exist errors

I'm trying to learn RoR and I keep getting pesky page doesn't exist pages. I deleted the index.html file out of my public folder and created a root route in my routes file but I still am getting that error. I am running ubuntu 10.04 with mod_passenger and ruby enterprise edition. ...

Nginx upload progress with Rails

I am having some trouble getting an upload progress working for my file upload. new.html.erb <%= form_for @image, (onsubmit="openProgressBar(); return true;"), :html => { :multipart => true } do |f| %> <%= f.file_field :photo %> </p> div> <div class="actions"> <%= f.submit %> </div> <br /> <iframe id="u...

Rails 3 - time_ago_in_words says "ABOUT 2 hours ago"...

Code: <%="#{time_ago_in_words(comment.created_at)} ago "%> What i'd like is for it not to have "ABOUT" in front of the 2 hours ago, which shows up for hours but not for minutes... Is there another function or a way to remove it without finding and replacing? ...

how to modify complex find_by_sql query w/ union into rails 3

here's the current query: @feed = RatedActivity.find_by_sql(["(select *, null as queue_id, 3 as model_table_type from rated_activities where user_id in (?)) " + "UNION (select *, null as queue_id, null as rating, 2 as model_table_type from watched_activities where user_id in (?)) " + "UNION (select *, null as rating, 1 as model_tabl...

Rails 3 - Creating a comment and then returning the Partial with JUST the new comment

Here's the flow I have... First, jquery posts the new comment to the server: $.post(this.action,$(this).serialize(),null,'script'); Then in the comments controller: def create @comment = lots of stuff going on here but it works... if @comment.save flash[:notice] = "Successfully created comment." respond_to ...

What does -%> mean in Ruby on Rails, compared to %>

I've always used <%= some_code %> to insert Ruby into HTML when using Ruby on Rails. I've just noticed that other projects sometimes use <%= some_code -%>. What is the difference? Thanks for reading. ...

rake aborted! undefined method `closed?' for nil:NilClass

rake solr:start throws this error rake aborted! undefined method `closed?' for nil:NilClass ...

Usefulness of db migrations rollback

Hi, Many people talking about db migrations, especially about its rollback possibility. I doubt, whether it is useful at all, because schema of db and model are tightly connected with application logic (MVC). Suppose i've done rollback of some migration. And what ? The application will not work, because its logic fully relies on db. ...

Problem viewing photos in Paperclip - routes error

I have set up Paperclip and ImageMagick successfully on my system, and files are uploading correctly, being resized, and and being saved into the right folders. I try to display those images in my view: <%= image_tag @customer.logo.url(:medium) %> No image is displayed. When I go to the image's direct url I get: Routing Error No rou...

How can I create a nokogiri case insensitive text * search?

Currnetly I am doing words = [] words << "philip morris" words << "Philip morris" words << "philip Morris" words << "Philip Morris" for word in words doc.search("[text()*='#{word}']") end When I was using hpricot I found where to downcase the results within the gem so I could just keep all my searchs lowercase, however nokogiri has ...

How I can call specified first app's rake task from second one.

How can I call specified 1st app's rake task from second one. Case: User on baseapp.com (RoR), fills up the reg.form BaseApp validates and stores data Than, with delayed_job/resque I should call subapp's rake db:bootstrap FORM_PARAM1 FORM_PARAM2 ... FORM_PARAM3 ...

RoR 3 - authentication with Authorization combined with Facebook Connect

I'd like to know what would be the best "practise" to use: Authentication Authorization Facebook connect I have seen authlogic has an Facebook Connect plugin. But the roles (authorization) haven't been described there. How would i do this? ...

Is there any way to disable Active Record in runtime (or just degradate due to DB down)

Hi! In my Rails 2.3 app there is a possible situation when database is down, but app still should work. I.e. I need to disable part of my application when database is down. E.g., have some method like is_database_up? that will return true if database is up. For now, if database crushes, whole app will crush too. Is there any way to hand...