What's a smart way of using ActiveSupport or perhaps regular built in Ruby functionality to take two arrays and merge them into a hash where each element in an array matches the element in a parallel array? imagine two arrays:
names = ["Danny", "Johnny"]
ages = ["25", "32"]
The end result should be a hash that looks like:
{"Danny" =>...
I've spent most of my time in statically typed languages (primarily C#). I have some bad experiences with the Active Record pattern and unit testing, because of the static methods and the mix of entities and data access code.
Since the Ruby community probably is the most test driven of the communities out there, and the Rails ActiveReco...
Hi everyone,
I'm following the Agile RoR book somewhat to apply it to a project for school. It's going good until I get to sessions. I continually get Authenticity Invalid Tokens and when I look at my sessions table in the database, there's a new session being created every time I refresh the page. Is that right or is something messed u...
Hi i have this starnge behavoir...
<%= link_to image_tag("image.png"), brain_path(1), :method => "put" %>
produces:
<a href="/brain.1" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.met ...[many rails code]... ;return false;"><img alt="Research_4" src="/images/image.png" /...
[
{
"id":"123",
"name":"House"
},
{
"id":"1456",
"name":"Desperate Housewives"
},
{
"id":"789",
"name":"Dollhouse"
},
{
"id":"10",
"name":"Full House"
}
]
How can I render to produce this JSON format from within Ruby? I have all the data from the DB (@result) and d...
Hello. How is it possible to debug rake tasks?
When I write debugger it does not start:
NoMethodError: undefined method `run_init_script' for Debugger:Module
from /usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby-debug-base.rb:239:in `debugger'
from (irb):4
If I run rake my:task --debugger rake returns me to console i...
I have an application (Rails 2.3.5) that I'm deploying to production Linux/Apache server using the latest Phushion Passenger/Apache Module 2.2.11 version. After deploying my original application, it returns a 500 error with no logging to production log.
So I created a minimal test rails application, with some active record calls to the ...
My application stores lots of its users friends' phone numbers. I'd like to allow users to associate names with these phone numbers, but I don't want to make users manually type in names (obviously).
I'm curious what the best overall approach is here, as well as the best way to implement it
Overall approach-wise, I imagine using Gmail ...
I have a model that sets one of its attributes based off of a form parameter that a user submits. The model is a child resource to a parent resource Home. A hypothetical example is the following:
A class Person has an age attribute. The user submits a birthdate as an HTTP POST parameter and from that, I need to derive the age of the use...
I'm about to start building a tumblr clone that handles multiple users (so premade clones like Gelato won't cut it) and I'm not sure which framework I'd like to build this is.
Right now, I'm only intending to build a prototype. Something I can get a dozen friends on to test the concept and grow to maybe a couple hundred users to prove ...
I have a sentence and correction model
class Sentence < ActiveRecord::Base
has_one :correction
class Correction < ActiveRecord::Base
belongs_to :sentence
and I'm trying find all sentences which don't have a correction. To do this I'm simply looking for corrections which don't exist i.e. whose id = nil. But it is failing and i ...
I have a time_select in which I am trying to set a time value as follows;
<%= f.time_select :start_time, :value => (@invoice.start_time ? @invoice.start_time : Time.now) %>
This always produces a time selector with the current time rather than the value for @invoice.start_time.
@invoice.start_time is in fact a datetime object but thi...
Hey guys,
My question is simple. Can I add either of the blow
:prompt => "Any"
:include_blank => true
to a form in form_tag.
Here is an example. I would like to add :prompt to the select_tag :condition and select_tag :category fields and am having trouble.
<ul id="homepage_searchbar">
<% form_tag junklists_path, :method => :get do...
In my rails app the model is fetching some XML and returning an array. I want each array item (they are all text typed) to ultimately be a cell in an HTML table.
Does the logic of turning the array elements into the HTML table belong in the controller or the view?
Of course either will work, I'd like your thoughts on best practice.
...
Hi,
I'm running through the Ruby on Rails tutorial at http://guides.rubyonrails.org/getting_started.html (adjusting where appropriate for Google's App Engine). All is well up till section 6.3: when I try to click "New Post", I get the following error:
Internal Server Error (500)
Request Method: GET
Request URL: http://localhost:8...
I saw this question and couldn't make use of it:
http://stackoverflow.com/questions/1034135/ruby-email-encoding-and-quoted-printable-content
I'd like to send out email as quoted-printable, but it's going out as unencoded text/html. Any help?
class UserMailer < ActionMailer::Base
def welcome_mail(user)
recipients user.emai...
I have an entries controller that allows users to add contact information the website. The user-submitted information isn't visible to users until the administrator checks a check box and submits the form. So basically my problem is that if I check the check box as an administrator while initially creating an entry (entries#new) the entr...
G'day guys,
I'm using fasterCSV and a rake script to parse a csv with about 30 columns into my rails db for a 'Trade' item. The script works fine when all of the values are set to strings, but when I change it to a decimal, int or other value, everything goes to hell.
Wondering if fasterCSV has built in int etc parsing or whether I'll ...
I'm interested in creating a system where the user can define the steps in a workflow.
Is there a gem that already handles this? I thought about one of the state machine gems, but they all seem to be for pre-defined states. I've been thinking maybe i can use state machine for the individual step types... An email step could have a few st...
I am trying to auto-populate a text field based on the value of another input field. Currently trying to do this using observe_field helper like this:
<%= observe_field(
:account_name,
:function => "alert('Name changed!')",
:on => 'keyup'
) %>
<% form_for(@account, :html => { :id => 'theform' }) do |f| %>
...