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?
...
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
...
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=...
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...
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...
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
...
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...
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 =...
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...
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...
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...
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.
...
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...
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 ...
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...
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 ...
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 ...
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...
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_...
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...