I am using rails beta 3 and I have a erb page named index.html.erb for discussions controller. In that page, I have a link as following:
<%= link_to 'Delete', {:action=>'destroy', :id=>@discussion}, :confirm=>"Are you sure", :method=>'post' %>
Which is supposed to generate a link to delete a discussion, however, the generated html is ...
If I do something like:
result = Appointment.find( :all, :include => :staff )
logger.debug { result.inspect }
then it only prints out the Appointment data, and not the associated staff data.
If I do result[0].staff.inpsect then I get the staff data of course.
The problem is I want to return this to AJAX as JSON, including the staff ...
I can't seem to get JSON.pretty_generate() to actually generate pretty output in Rails.
I'm using Rails 2.3.5 and it seems to automatically load the JSON gem. Awesome. While using script/console this does indeed produce JSON:
some_data = {'foo' => 1, 'bar' => 20, 'cow' => [1, 2, 3, 4], 'moo' => {'dog' => 'woof', 'cat' => 'meow'}}
som...
I'm trying to learn Rails better by looking at example applications, and while looking at this line of the source of railscasts.com, I noticed it does this:
<div class="episodes">
<%= render @episodes %>
</div>
What exactly is going on here? Why isn't this documented on the render function? Or is it?
...
Hi
Say I have a model Taggable has_many tags, how may I find all taggables by their associated tag's taggable_id field?
Taggable.find(:all, :joins => :tags, :conditions => {:tags => {:taggable_id => [1,2,3]}})
results in this:
SELECT `taggables`.* FROM `taggables` INNER JOIN `tags` ON tags.taggable_id = taggables.id WHERE (`tag`.`ta...
Hey. I would like to understand what "class << self" stands for in the next example.
module Utility
class Options #:nodoc:
class << self
def parse(args)
end
end
end
end
Thx!
...
I have a form that has a nested form like this:
<%- for subscription in @task.subscriptions -%>
<%- semantic_fields_for "task[subscription_attributes][]", subscription do |subscription_form|%>
<%- subscription_form.inputs do -%>
<%= subscription_form.input :workhours, :label => subscription.user.full_name%>
...
In a Rails app, I have a model, Machine, that contains the following named scope:
named_scope :needs_updates, lambda {
{ :select => self.column_names.collect{|c| "\"machines\".\"#{c}\""}.join(','),
:group => self.column_names.collect{|c| "\"machines\".\"#{c}\""}.join(','),
:joins => 'LEFT JOIN "machine_updates" ON "machine_upd...
In my current project (Rails 2.3) we have a collection of 1.2 million keywords, and each of them is associated with a landing page, which is effectively a search results page for a given keywords. Each of those pages is pretty complicated, so it can take a long time to generate (up to 2 seconds with a moderate load, even longer during tr...
I need to push my rails code into stating environment from github. And then deploy this app into engineyard in staging environment. Could some please give me step I need follow
...
So I'm building a blog engine which has /articles/then-the-article-permalink as it's URL structure. I need to have prev and next links which will jump to the next article by pub_date, my code looks like this:
In my articles#show
@article = Article.find_by_permalink(params[:id])
@prev_article = Article.find(:first, :conditions => [ "pub...
I have a live rails website and I want to have a form with a lot of fields on it. I have set up validations and allowed formatting for every field. I've tested it quite a bit and it seems to catch anything I throw at it.
I think it's almost ready to go live, but I want to quadruple check if there's anything else I should do to protect it...
Hi there,
I am using Amazon S3 to back up my Rails app's mysql database. And I am using astrails-safe plugin to do that and I got the "Your previous request to create the named bucket succeeded and you already own it. (AWS::S3::BucketAlreadyOwnedByYou)" error back whenever I try to update it.
I have checked that the folder in which I ...
So, I'd like for a user to see an error message if he submits a comment and the :name is blank (typical error message, don't need help with that). However, I'd then like to allow the user to skip that validation once he's been notified that "we like all comments to have a name." So, he submits the comment once, sees the notification, t...
I'm working on unit testing an ActiveResource model in my Rails application. I have my ActiveResource::HttpMock code in my test file as follows:
ActiveResource::HttpMock.respond_to do |mock|
mock.get "/audience/42/people/1.xml", {"Authorization" => "Basic VTExbTJCTzhkZzNMOmFpdU1nbHZJT2taakdPV3A=", "Accept" => "application/xml"}, @some...
I'm buiding an HTML/jQuery site where almost all the content comes from remote JSON data. I'm having trouble coming up with a good way to store and access the data in the future (scope-wise).
Currently, I've written a jQuery plugin that gets the JSONP data when the site loads. But I have other functions and jQuery plugins that need to ...
I know named_scope has been changed to scope in rails 3.
How do I perform default_scope in rails 3, I've had a good google but found nothing for defaults scopes.
...
Hey Guys,
This one might be a little confusing. I'm using AMCharts with rails. Amcharts comes with a PHP script to export images called "export.php"
I'm trying to figure out how to take the code in export.php and put it into a controller.
Here is the code:
<?php
// amcharts.com export to image utility
// set image type (gif/png/...
Hey we have a library class (lib/Mixpanel) that calls delayed job as follows:
class Mixpanel
attr_accessor :options
attr_accessor :event
def track!()
..
dj = send_later :access_api # also tried with self.send_later
..
end
def access_api
..
end
The problem is that when we run rake jobs:work: we get the follo...
Rails has an annoying "feature" which displays ALL validation error messages associated with a given field. So for example if I have 3 validates_XXXXX_of :email, and I leave the field blank I get 3 messages in the error list. This is non-sense. It is better to display one messages at a time. If I have 10 validation messages for a field d...