ruby-on-rails

Logging in with webrat, celerity doesn't recognize that.

I'm using cucumber with webrat, and I am just starting to integrate culerity/celerity. My webrat login steps have been working great, and I have them as a Background for many of my scenarios. The problem is that although I can log in successfully via webrat, my celerity specific step definitions don't seem to recognize that. I can check ...

What's an elegant way to conditionally add a class to an HTML element in a view?

I occasionally have to add a class to an html element based on a condition. The problem is I can't figure out a clean way of doing it. Here's an example of the stuff I've tried: <div <%= if @status = 'success'; "class='ok'"; end %>> some message here </div> OR <% if @status == 'success' %> <div class='success'> <% else %> <d...

ruby on rails - ultrasphinx

Ruby on Rails - UltraSphinx Hi guys, I'm using Ultrasphinx for the search thing. My question is : I have the "rake ultrasphinx:daemon:start" running in the background. Now, should I have a cron job that does "rake ultrasphinx:index" regularly or will the daemon take care of indexing whenever a new object is created. Please, let me kno...

Normalizing data in rails

I created a rails model by doing script/generate model Customer name:string address:string city:string state:string zip:integer [...] I filled the database with 5000 customers and started building my app. Now I've realized my model isn't normalized: I often have multiple customers at the same address! If I wish to do something per-add...

What happened to Builder::XmlMarkup in Rails 3?

I'm struggling with the atom_feed method in a RoR 3 project. The method complains about a undefined local variable or method `xml' error so I tried passing the XML builder as an option to the atom_feed (i e atom_feed({:xml => Builder::XmlMarkupet.new})) but when doing so I get a NameError: uninitialized constant Builder exception ins...

find_with_ferret , multiple model not working

I have 2 models A and B. class A < ActiveRecord::Base has_one :b acts_as_ferret :fields => [:title,:description] In a_cotroller, i wrote: @search=A.find_with_ferret(params[:st][:text_search],:limit => :all).paginate :per_page =>10, :page=>params[:page] The above title and description search is properly working. class B < Active...

Rails - how would you go about coding an index action / view like the user profile in stack overflow.

I've decided to reopen this because I want to here more peoples views on this. I'm not looking for full code but rather your approach. Stackoverflows user profile (user index) is pretty complex, it has around 7 tabs, each one displaying the data in different way. Its almost like they are mini views each one using a different partial fo...

Changing Redmine URL structure and adding other domains

I have set up a Redmine installation on a Windows server using the BitNami stack. I would like to change the path of the URL that is used to address redmine at the moment (www.example.com/redmine/...) if possible without physically relocating the installation. map additional subdomains to certain projects (www.example2.com pointing...

Ruby 'gem install' won't work

I am behind a firewall with internet blocker installed. I have power user previlage so I was able to install from git etc. But I am facing this only when I try installing 'gem'. Here is what I get, I think it says it recieved some error instead of a gzip. Is there any config that I need to change? or any port or anything?? does it use ...

remote_function and select boxes in Rails

I have a select box that needs to submit it's value to a server side controller on change. The submit works. The value of the changed element is however not sent. I've scoured some examples online, but none seem to work remote_function( :url => some_remote_function_path, :with => "'key1='+$('elem_id').value +'&key2='+$('ele...

I am trying to manipulate nested parameter before saving the model, but i miss something

I cant see what im missing. I have and Order with nested Items, these Items each have a Kind. I want to manipulate the kind_id param from each Item but the "f[:kind_id]" always return 0. @order.items.each do |f| f[:kind_id] = Kind.find_by_name(f[:kind_id]).id end the params i get is {"authenticity_token"=>"7wz7ARjwcVvCR/bpp/T04JQI...

Rails validating full_name

Hey... how would you validate a full_name field (name surname). ...

how do I link a sass stylesheet to rails templates?

Hi - This is a newb question, I know, but I can't seem to figure it out. I've been using rails for a while but always went with regular css. Not sure if I'm supposed to use <%= stylesheet_link_tag 'style' %> I store my sass file in public/stylesheets/sass/style.sass, and did the whole $ sass --rails /path/to/app thing. Oh, I'...

How install gems locally?

I have no internet connection on server machine, so I need to install gems locally. I tried gem install rails-2.3.4.gem But, I'm getting errors. How Can I install gems locally. Thanks. ...

How to do a "join" with an anonymous scope in ruby

Hey guys (and girls ^^) !!! Does sommebody knows how to do a "join" with an anonymous scope in ruby ??? With a named scope you just have to add ":joins =>....." but i can't really find the way to do it with anonymous ones ... . Thx in advance for the help ;) ...

How to override a render to create a custom "render :my_format => argument" in rails 2.3(.5)?

Hey! I would like to create a custom render as specified in title. For instance, I have my controller: class MyController < ApplicationController def index respond_to do |format| format.html # index.html.erb format.xml { render :xml => @objs } end end end , but I would like something like this: class MyCont...

How does the yield magic work in ActionView?

I was looking at how content_for works and observed the block.call in the capture_erb_with_buffer method. It apparently magically writes to the buffer variable which is then pruned. However, this I believe is deprecated and you can just call <%=yield :tag%> now. How does this work? If I call yield from an ERB template where does that yie...

How do I find where a ruby method is declared?

I have a ruby method (deactivate!) that is on an activeRecord class. However, I can't seem to find where that method is declared. There have been numerous developers on this project, so it could be anywhere. There is a deactivate! on an unrelated class, but it doesn't seem to get called. Any ideas how to find all the superclasses for...

where from does paperclip get the name of original file?

i started using nginx upload module (which creates upload files like /tmp/000121545) but i need paperclip to use original filename while saving files (like /public/avatars/LuckyLuke.jpg) previously in the parameters Rails were passing just "avatar"=>#<File:/tmp/RackMultipart20100413-6151-t3ecq0-0> no original filename as well, so ...

jeditable dynamic target value

I'm using jeditable and it works really great! I'm just having some trouble figuring out how to dynamically change the target URL. jeditable is bound to a table of values that I want to edit inline. So I have: <td id="<%= col.id %>_<%= i.id %>" class="edit"> The id is a mashup of two values I need to know to edit this item on the se...