I'm trying to create a record within a join table from the action of a button. To explain, I would have an events model and would like to track selected events from each user.
I used the HABTM relationship since I dont really need any extra fields.
User.rb => has_to_and_belongs_to_many :events Event.rb => has_to_and_belongs_to_many :us...
I'd like to start the rails console and create database entries in a database that isn't the default database, such as the testing database. I'd appreciate any help.
...
Hi all,
Need a little help with a SQL / ActiveRecord query. Let's say I have this:
Article < ActiveRecord::Base
has_many :comments
end
Comment < ActiveRecord::Base
belongs_to :article
end
Now I want to display a list of "Recently Discussed" articles - meaning I want to pull all articles and include the last comment that was adde...
I have some models all linked together in memory (parent:child:child:child) and saved at the same time by saving the top-most parent. This works fine.
I'd like to tap into the after_create callback of one of the children to populate a changelog table. One of the attributes I need to copy/push into the changelog table is the child's f...
I'm listing the data from one of my models in a table
<% @events.each do |event| %>
<tr>
<td align="center"><%= button_to "Add", :controller => 'personal', :action => "add" %> </td>
<td><%=h event.name %></td>
<td><%=h event.description %></td>
<td><%= link_to 'Show', event %></td>
<td><%= link_to 'Edit', event %></td>
<% end %>...
This javascript code does not work in IE8, but works in Firefox and Google Chrome:
<% content_for :head do %>
<script type="text/javascript">
document.observe("dom:loaded", function(){
// Observe toggler
$('toggle_all').observe('change', function(){
var toggle = $('toggle_all').checked;
$$('.check_boxes...
Working on Rails code for a bit has started me on the spiral into obsessively customising my dev environment (I say obsessive as at the last Rails meetup I went to there was some guy who was raving about shaving milliseconds off each line of code and therefore upto half an hour a day... I hope I don't become that guy...)
I spend most of...
Why is Ruby, and Ruby on Rails (1.8.6 One Click Installer, local database) so ruddy slow on Windows?
ruby script/server - 30 seconds
rake test - 45 seconds
etc.
Yet, when I pop over to a much slower linux box, it's virtually instantaneous. I've checked everything - no significant CPU processes running, no network issues... and so on...
Given a simple namespaced route
map.namespace :api do |api|
api.resources :genres
end
how can I reuse this block but with another namespace?
Currently I'm achieving that by writing another routes hacked on the fly
map.with_options :name_prefix => 'mobile_', :path_prefix => 'mobile' do |mobile|
mobile.resources :genres,...
Is it possible to change the Passenger application pool size at runtime? Ie, without restarting apache, and without disrupting active visitors?
The same time every day we have a background job run. It is very memory intensive. Since during that time, traffic on the site tends to be relatively low, I would like to automatically scale dow...
Hey guys,
I have the following classes:
class Vigil < ActiveRecord::Base
after_update :do_something_cool
private
def do_something_cool
# Sweet code here
end
end
class NewsFeedObserver < ActionController::Caching::Sweeper
observe Vigil
def after_update
# Create a news feed entry
end
end
Everything works ...
Hi - I hope someone can advise / direct / shed some light on :
i have a rails application that uses Authlogic for authentication.
i would like to incorporate cometchat into this application - (in reality any chat IM would do - but cometchat seemed to fit nicely because ajax-im does not like windows)
The environment is the following : T...
I want to give my users the ability to choose how their public page is displayed from 5 different layouts. I assume I'll need 5 different css files according to layout and then need to pass that into stylesheet_link_tag
I know only how to do it using if then statements. I don't suppose that is the best way. Any help...also could it be d...
I have a table with a float called 'cost' and timestamp called'created_at'.
I would like it to output an array with the summing the costs for each particular day in the last month.
Something like:
@newarray = [] #creating the new array
month = Date.today.month # Current Month
year = Date.today.year # Current Year
coun...
Hi,
I'm building a Flex 4 + Rails 2.3.5 application. First I was using XML to pass date through and I used to get an error complaining about Authenticity Token which I passed manually then to get through the error.
After that I re-factored my code to use RubyAmf which seems to be working but I didn't pass in the authenticity_token at f...
We are developing a web application wherein with about 50% of write requests, we end up pushing data to multiple data stores and inserting and updating significant number of records in those data stores. To improve the response time, we want to process such requests asynchronously in the background.
Our web application is being written ...
Is there any specific format for a geohash value? Can I use Geohash.encode(latitude,longitude,precision="8") in ruby script? What is the maximum value that precision attribute can take? Thanks in advance for any help.
...
Hi,
Rails 3 allow to send static files directly and more performantly to HTTP clients and bypassing your app server process (as described see http://john.guen.in...)
send_file '/path/to.png', :x_sendfile => true, :type => 'image/png'
I want to deploy my app on heroku.
heroku use Nginx 0.6.32 (see http://docs.heroku.com/aspen).
Does...
I have dynamic form which has a set of values. I created a partial which contains text fields which I display. Next to each of them I would like to display a label containing the title of the text. For instance First Name, and Last Name would not be known previously. How do I go about doing that?
It seems that I cannot access the attribu...
I'm working on an app that will transcode videos that are sent into a drop box. Because videos could take anywhere from a few minutes to a few hours to be sent to the dropbox, I want to be sure the file is done being written before my app begins processing it.
I thought the easiest way to do this would be to check the size of the file ...