Hi,
I'd like to view each Project by Client, but unsure how to use Datamapper to get this information out. I have my relationships setup like this:
class Client
property :id, Serial
property :name, String
has n, :projects, :foreign_key => "company_id"
end
class Project
include DataMapper::Resource
property :id, Serial...
HI
whats the best way to implement a simple search in rails to retrieve all models with the same date?
e.g retrieve all customer with birthday date on 23-10-1975, which will be of a date format.
i.e
create_table "customer", :force => true do |t|
t.string "f_name"
t.string "m_name"
t.string "l_name"
t.date ...
Im not very updated in the event-driven/concurrency area in node.js.
I wonder, is it possible that node.js would replace ruby/rails completely in the future?
Or is it more like an extension to ruby/rails for the real time features?
...
Hi, I'm trying to flatten an array for my form.
def update
@tour = Tour.find(params[:id])
params[:tour][:hotel_ids][0] = params[:tour][:hotel_ids][0].split(',')
...
This results in:
"hotel_ids"=>[["1","2"]]
Naturally I want it to be
"hotel_ids"=>["1","2"]
My Form:
<%= text_field_tag 'tour[hotel_ids][]', nil %>
Hope anyon...
There once was a Facebooker tutorial which was a facebook app but for the last few weeks I'm greeted with just a blank page when I go to it. Does anyone know of any good resources for getting started with the Facebooker plugin for Rails?
I was kind of surprised at how difficult it is to find this... any help would be greatly appreciate...
Is there a way to access form errors in the controller? In the view I can access form errors using
from.error_messages
I want to list errors in a flash message before may layout header, how do I go about accessing those errors in the controller so I can assign them to a flash message?
...
I'm working in the Insitiki code and trying to extend the maruku syntax to generate some custom html tags.
Example:
|youtube 0FWPr6u8YF |
Should print the html code as follows:
<object data='http://www.youtube.com/v/01hcB2zmMqM' style='width:425px; height:350px;' type='application/x-shockwave-flash'><param name='movie' value='http:/...
I've just recently started writing my own gems. One of them requires the gnuplot gem, like so:
module Rocker
require "gnuplot"
# ... module code here ...
end
It works great, right up until I add my gem to config/environment.rb on one of my Rails projects. Then, not a single page will load. I get errors like this:
TypeError in ...
I am writing a helper that needs to call another helper, which generates html. How do I do that?
...
I would like to setup a crontab for my thinking_sphinx search feature. I am not using any ruby gems for this.
this is my command
*/59 * * * * cd path && rake thinking_sphinx:index RAILS_ENV=production
The syslog gives me this:
CRON[2890]: (user) CMD (cd path && rake thinking_sphinx:index RAILS_ENV=production)
Yet the thinking_...
In my database on heroku, it shows contactemail.created_at = "2010-08-08 17:16:19"
However, when I use puts.contactemail.created_at I get something different. I get:
2010-08-08 10:11:13 -0700
I need to input that value through an API to another application, and I am pretty sure that the first format is what it wants. If it doesn't t...
I am developing a rails application that will eventually contain products, users, and orders. For now I am just trying to get their 'brochure site' up. Rather than build it twice I thought to simply start with the rails application making it easily to rapidly move on as they need. That said...I am looking for advice on the best way to bu...
I have a model called Contact.
I have added the following method:
def all_completed_events
# for a given Contact, return all contact_events records that exist and where sugarcrm = false
return (self.contact_letters + self.contact_postalcards + self.contact_emails + self.contact_voicemails + self.contact_calls)
end
What is mis...
app/models
class Amodel < ActiveRecord::Base
end
class Bmodel < Amodel
end
class Cmodel < Bmodel
end
db/migrate
create_table :amodels do |t|
t.string :type
end
on script/console...
$ script/console
Loading development environment (Rails 2.3.4)
>> Cmodel.create
=> #<Cmodel id: 1, type: "Cmodel">
>> Bmodel.find(:all)
=> [#<...
This is when using a view file to generate an excel file. like:
in controller:
headers['Content-Type'] = "application/vnd.ms-excel"
headers['Content-Disposition'] = 'attachment; filename="report.xls"'
then in view:
<table><tr><td>foo</td><td>bar</td></tr><table>
Is it possible to add formatting such as color to cells? like:
<td st...
I've been learning Hobo, an awesome wrapper for Ruby on Rails that I'm finding extremely DRY and n00b-friendly.
But how do I set Notepad++ to automatically recognize .dryml files such that appropriate syntax highlighting is applied?
...
I am making a dynamic URL in my rails app like
http://localhost:3000?#{something}=#{something1}
How do I get rid of the hardcoded domain name (localhost in this case). I want to deploy this app to heroku and heroku will give its own domain name. I don't want to again change my code to suit the domain name that heroku gives.
Is thi...
Rails 3 has some unobtrusive javascript which is pretty cool.
But I was wondering what the best way is to include additional JS for a particular page.
For example, where I might have previously done:
<%= f.radio_button :rating, 'positive', :onclick => "$('some_div).show();" %>
We can now make it unobtrusive with something like
<%= ...
This is the structure of my database in Ruby on Rails:
user have many notes
notes have many categories
categories have many notes
The relationship between notes and categories is has_many :through, I have a model named NoteCategory and a note_categories table.
The note model has a date field, which represents the date the note was c...
render :partial generates only one time on escape_javascript
eg
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("#addPerson").click(function(){
$("#user tr:last ").after("<%= escape_javascript(render :partial => 'user_item', :locals =>{:user_item => User.new}) %>");
...