ruby-on-rails

Ruby 1.8.6 LocalJumpError when dealing with ActiveRecord

I have the following code: Tag.find_all_by_company_id(4).each.collect{|tag| tag.name }.join(",") (Essentially I'm trying to build a JS array of tag names) When I run this code, I get: LocalJumpError: no block given from (irb):13:in `each' from (irb):13 Any ideas? ...

Debug Error in Ruby script

I'm very new to Ruby. I have the following piece of code which is giving me an error. class ItemsController < ApplicationController def populate Location.all.each { |l| place = l.radar_place next if !place news_items = place.radars news_items.each { |ni| t = Lbs2.new t.lat = l.lat ...

RSpec spec fails when invoked via "rake spec", passes when invoked via "spec spec"

One of my specs fails when I run it via "rake spec" but passes when I use the RSpec executable "spec". The spec fails when I use a url helper in a ActionMailer view. The error message is: auction_url failed to generate from {:action=>"show", :state=>"asd", :slug=>"asd", :controller=>"auctions"}, expected: {:action=>"show", :controller=...

Python, PHP or what scripting language is the best for automating web-interaction tasks?

Hi, I wonder what is the best scripting language for doing the following: I go to this website http://structure.usc.edu/make-na/server.html and the input a two lines string like: ATGC TATG Afterwards I push the "Make NA" button, so I download the resulting file, which I change the name before downloading it. I would like to do t...

How do I get a value from a composite key table using a Rails model?

I have the following schema (* means primary key): languages id* english_name native_name native_to_target_language native_language_id* target_language_id* target_language_name overview_text (target_language_name is the name of the target language as written in the native language). I want to get the value of target_la...

Paperclip plugin : Change image folder permissions

By default when I upload new images, the folder created have 777 permissions Is there a way to restrict permissions on the new folders? Thanks ...

polymorphic activerecords in rails?

Hi so I have a list of 'areas' that are just areas of my site. I want to be able to insert them in to the database and say what type of area they are, this could be the name of the model that inherits from a base Area. This way I can write a generic controller which uses different views and different logic from the loaded model to decide...

Apache2, Git, Capistrano & Rails - creating symlinks

I'm sort of stuck with adding symlinks to my app on the server. I currently have the following in .gitignore: /non-public/system/uploads/* I basically don't want Git to store the contents of the upload directory. So far so good. On my server, inside my deploy.rb, I have the following: namespace :customs do task :symlink, :roles =...

Factory Girl: Automatically assigning parent objects

I'm just getting into Factory Girl and I am running into a difficulty that I'm sure should be much easier. I just couldn't twist the documentation into a working example. Assume I have the following models: class League < ActiveRecord::Base has_many :teams end class Team < ActiveRecord::Base belongs_to :league has_many :play...

OpenLayers / MapLayers - how to attach a Handler to a Control?

I'm using OpenLayers in a Rails app - through the MapLayers plugin. The examples for adding controls look easy - very similar to the example code on the OpenLayers.Control class - @map = MapLayers::Map.new("map") do |map, page| page << map.add_layer(MapLayers::GOOGLE) page << map.add_layer(MapLayers::YAHOO_HYBRID) page << map.ad...

Rails with Authlogic, how to remove a default validation?

Hi there, I am building an Rails App with Authlogic. But I don't want to force the user to fill in the e-mail, or even username! Therefore, I believe i want a methods to skip those validations.. But I don't just want to bypass all other validations. Is there a method for that in Authlogic, or do I need to hack in the gem? The reason is...

Override rails render method and replace content

I want to scan my erb files looking for specific custom HTML tags (I have done this part) and then before rendering, intercept these tags and replace their html output. I can't find any info relating to this sort of activity in RAILS. Maybe I am not looking in the right place. ...

Get an array containing the number of posts created in the past 2 weeks

I want to create sparklines that illustrate the number of posts created on my blog in the last 2 weeks. To do this, I need to first generate an array that contains the number of posts created on each day during the period in question. For example, this array: [40, 18, 0, 2, 39, 37, 22, 25, 30, 60, 36, 5, 2, 2] generates this sparklin...

Facebooker Built In Data Retrieval Methods Return "No info set for this user" error

I've gone through the Facebooker msg archive, google, etc and found a couple messages dealing with this and they basically say "Go look at the Facebook docs and see what is happening". I did that, but I'm still not clear what is going on and why I'm not able to retrieve my profile or status arrays using Facebooker. I'm starting to think ...

Rails - No "Mate" command for .gitignore - Using InstantRails?

Hey guys, This is my first time making an app with any kind of version control and the idea of it sounds awesome. I'm just getting started and using some tutorials to figure it out. I created my app.... rails example Then started up git..... git init and now I'd like to make an .gitignore file which most tutorials are using mat...

Rails generate url from array with parameters

Hi I wondered if there's some way to do this polymorphic_path([@page, @image]) but like this polymorphic_path([@page, :image_id => 1]) It's for the purposed of refactoring where I'd like to throw various params into the array and where they're null, they're ignored, but otherwise they generate the relevant nested url. Thanks in ...

Rails select tag not working when value different from display or when value in database is integer?

In my rails form I'm using the select tag. <%= f.select :featured, Timeline::TIMELINE_FEATURED, :prompt => "Select" %> The definition of TIMELINE_FEATURES is Yes and No to be displayed, but stored as INT in database: TIMELINE_FEATURED = [ # Displayed stored in db ["No", "0"], ["Yes", "1"] ] My problem ...

Rails: Form confirm message with data from the submitted form

Trying to make a custom :confirm message for a rails form that returns data from the submitted form--not just a static string. <% form_for @foo do |f| -%> <% f.text_field :number_of_bars -%> <% f.submit :confirm => Are you really sure you want to use ##number_of_bars## bars? -%> The idea is if the user puts in the number 3 in the numb...

rails, set polymorphic association

How should the keyword_list=(value) method look ? class Keyword < ActiveRecord::Base belongs_to :keywordable, :polymorphic => true end class Article < ActiveRecord::Base has_many :keywords, :as => :keywordable #getter def keyword_list keywords.map {|keyword| keyword.name + ","}.to_s.chop end #setter def keyword_...

CanCan gem | cannot :index, User

Very basic user model, I wish the admin user to :manage all else cannot :index, User and some other options, but when I try and block non admin users from viewing the user index, the admin user also has not access. this is my ability.rb class Ability include CanCan::Ability def initialize(user) user ||= User.new #guest use...