I have two models Station and Broadcast. Broadcast belongs_to Station and has a station_id column.
I don't know how to make new method in BroadcastController to expect the station_id value and how to create a new Broadcast with right station_id in it.
...
Hello!
I am using Rails 3 and the Facebook Javascript SDK and when I login a cookie is created.
I want to be able to extract data from this cookie using Rails.
I got a PHP code that does the trick but I want to use Rails code. What does the below code written in PHP look like in Rails?
function get_facebook_cookie($app_id, $applicatio...
Ok so i have an application that i use this jquery
$("#band_events").load("/load_events/"+ escape($('#request_artist').val()), successCallback );
It works great but if #request_artist is R.E.M. or somehthing with decimals or something weird rails has problems like
ActionController::RoutingError (No route matches "/load_events/R.E.M....
I downloaded, setup all the gems for http://github.com/bestbuyremix/BBYIDX
Now when I type:
rails script/server
I got the output, but server doesn't start??
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/i...
In this project in github, it doesn't have a 'GEMFILE', but it has a .gems file that looks like:
rcov
rails --version 2.1.1
mash --version 0.0.3
haml --version 2.0.3
color --version 1.4.0
ruby-hmac --version 0.3.2
calendar_date_select --version 1.15
fastercsv
oauth --version 0.3.6
oauth-plugin --version 0.3.14
httparty --version 0.4.3
...
I have a venue model and i want to do this
Venue.find_or_create_by_
but i only want a new venue to be created if one with the same name and date do not already exist
For example
=> Venue(id: integer, location: string, showdate: datetime, created_at: datetime, updated_at: datetime)
A venue is unique and needs to be created if the l...
When you run db:seed, where is the script that inserts seed data into the db?
...
I'm new to rails and and I'm on the urge of learning Associations.
I'm using Rails version 3.
I have a user model and post model.My need is as below:-
Models
class User < ActiveRecord::Base
has_many :post
end
class Post < ActiveRecord::Base
belongs_to :user
validates_associated :user
end
Schema
ActiveRecord::S...
Hi,
I'm trying to test a rails, application, and in one particular case, I need to create a TimeWithZone object inside my testcase. So I write sth like this:
started_at = ActiveSupport::TimeWithZone(started_at, Time.zone)
only to get an error:
NoMethodError: undefined method `TimeWithZone' for ActiveSupport:Module
I tried requiri...
Hello. I'm diving into RoR and as I'm going through the tutorials, scaffolds, and docs, I'm coming across some code that confuses me. For example, I just read up on the 'redirect_to' method, but the guide I read didn't cover the example of redirecting to an instance var, such as the code that is generated in a typical scaffold...
# PO...
So the rails code I used:
<%= image_tag("logo.png", :alt => "Sample App", :class => "round") %>
produces the HTML:
<img alt="Sample App" class="round" src="/images/logo.png" />
But when I load the page, it shows the broken image symbol.
What gives?
I am loading it in the latest stable build of Chrome on Windows, fyi.
As an asid...
As I'm diving into RoR, I'm learning about some of the view asset tags and trying to undertand the benefit of using them instead of just using straight html. For example, what's the benefit, aside from brevity, of using <%= stylesheet_link_tag "main" %> instead of just writing out the actual HTML? Then I came across the cache option th...
I'm looking for some (more than intro-level) database optimizations, not just for Rails but for SQL in general.
In Rails, how/when do you start using these?
cache_counter
caching ids in a table (user has_many roles, so the user table gets a role_ids serialized column, since every request requires fetching the roles).
Are these types...
I'm diving into Ruby on Rails and I'm trying to get a grasp on the available docs for the API. I'm trying to find out what the list of "options" are for the redirect_to method in the ActionView API. In the RoR API docs, it says...
redirect_to(options = {}, response_status = {})
but it doesn't list what the available options are.
...
The embedded ruby code in my view is...
<p id="notice"><%= notice %></p>
but when the URL reads...
http://0.0.0.0:3000/projects/3?notice=Project+was+successfully+created
the generated HTML is...
<p id="notice"></p>
I'm expecting it to read...
<p id="notice">Project was successfully created</p>
What gives?
EDIT: Here's my ...
So I am trying to pass a primary key (id) value to my create method and it doesn't work.
Is there a way to do this in rails?
Category.create!(:id => 2828, :name => 'Some Category')
...
Hi folks,
I'm trying to run individual tests through ruby test/unit/mytest.rb, but I always get a "no such file to load - test_helper" error. Google brought up a few suggestions, but none of them worked for me. I'm running Rails 3.0, Ruby 1.9.2 (through RVM) on Ubuntu 10.10
Here's what I've tried so far - any suggestions really appreci...
Hi,
I have two projects ahead and I'm pretty new at Ruby and Ruby on Rails. It's real fun! =) Besides, I count myself fluent in C++ and Java (and JavaEE), but have very very few experience with C#.NET and Ruby. Also, I'm pretty eager to learn Ruby, but don't really want to waste time to develop skills on C# - which is pretty similar to ...
I have a title on a blog goes like this Main Idea, key term, key term, keyterm
I want the main idea and the key terms to have a different font sizes. First thing that came to mind was to search for the first comma and the end of the string and replace that chunk with the same thing but surrounded by span tags with a class to make the fo...
Hi,
I've got this:
a = [[123,1],[124,1],[125,1],[126,2],[127,3],[128,3]]
And I would like to turn a into b:
ordered by value
random within array of value
// updated:
b = [[124,123,125],[126],[128,127]]
How to do this in ruby? Im using rails.
...