[Rails] best way to use ajax when paginating multiple tables

2010-06-21 Thread Scott Kulik
for example, i'm trying to paginate results on this home page http://wlodb.com (forum posts, items, compounds, etc...) I have followed this railscast http://railscasts.com/episodes/174-pagination-with-ajax to get ajax and will_paginate working on the pages with only one table...but i'm not sure

[Rails] Re: help finding database items that lost parent item

2010-04-26 Thread Scott Kulik
Marnen Laibow-Koser wrote: Scott Kulik wrote: Frederick Cheung wrote: On Apr 25, 1:57�am, Scott Kulik li...@ruby-forum.com wrote: updating the database when a users has problems with their private messages page. I'm wondering if someone knows a good way I could scan the the pm's table

[Rails] Re: help finding database items that lost parent item

2010-04-25 Thread Scott Kulik
Frederick Cheung wrote: On Apr 25, 1:57�am, Scott Kulik li...@ruby-forum.com wrote: updating the database when a users has problems with their private messages page. I'm wondering if someone knows a good way I could scan the the pm's table and delete messages that no longer have a user

[Rails] help finding database items that lost parent item

2010-04-24 Thread Scott Kulik
I have a table for private messages similar to: PMS: title body sent_to (foreign key to users table) sent_from (foreign key to users table) When I originally set it up I didn't have it automatically a users pm's when that user was deleted. So...I have basically been manually updating the

[Rails] how to get rake task to delete dependents

2009-09-12 Thread Scott Kulik
is there a way i can get a rake task to destroy the dependents declared in the model when an item is destroyed? here is my rake task code: task(:deleteFakes = :environment) do @items = Item.find(:all, :conditions = 'items.fake = true', :order = 'name') @items.each do |item|

[Rails] Re: how to get rake task to delete dependents

2009-09-12 Thread Scott Kulik
Scott Kulik wrote: is there a way i can get a rake task to destroy the dependents declared in the model when an item is destroyed? here is my rake task code: task(:deleteFakes = :environment) do @items = Item.find(:all, :conditions = 'items.fake = true', :order = 'name

[Rails] query pulling too many fields

2009-04-16 Thread Scott Kulik
i'm a little confused here on what's happening. i have two tables ITEMS and ITEM_TYPES ITEMS (belongs_to :item_type) id name item_type_id ITEM_TYPES id name here is my Item.rb model code for my query: find(:all, :select = 'items.name, item_types.name', :include =

[Rails] Re: query pulling too many fields

2009-04-16 Thread Scott Kulik
Harold wrote: The find's :select option is ignored when you combine it with the :include option. On Apr 16, 8:58�pm, Scott Kulik rails-mailing-l...@andreas-s.net thanks. i removed the include and did my joins manually. i guess that's probably the best way: find(:all

[Rails] help with search query

2009-04-13 Thread Scott Kulik
ok, here's my dilemna...i have a site that has a list of item combinations (aka compounds) for a computer game. i'm having a hard time coming up with a good way to search a compounds result and the items that are contained within the compound. the formulas are setup like: COMPOUND =

[Rails] Re: what is taking so long to display this page?

2009-03-27 Thread Scott Kulik
Denis Haskin wrote: And where was it going? ;-) dwh i had some cpu intensive code to validate the items on the page and i screwed up the query so it was running the code on all 7000 rows in the table instead of just the 50 displayed on current page. doh! -- Posted via

[Rails] what is taking so long to display this page?

2009-03-26 Thread Scott Kulik
I have a page that does a lot of calculations...that for some reason takes 19 seconds to load when running in my development environment. Looking at my logs I can see Rendering took .8 seconds and the DB took 2.38 seconds: Completed in 19.81708 (0 reqs/sec) | Rendering: 0.80910 (4%) | DB:

[Rails] Re: what is taking so long to display this page?

2009-03-26 Thread Scott Kulik
Rob Biedenharn wrote: You can try New Relic's Rails Performance Monitor [1] to find out some of those details. [1] http://newrelic.com/get-RPM.html -Rob Rob Biedenharnhttp://agileconsultingllc.com r...@agileconsultingllc.com thanks rob! i just installed the plugin and I can see

[Rails] Re: select_tag help

2009-03-21 Thread Scott Kulik
Frederick Cheung wrote: On Mar 21, 1:44�pm, Scott Kulik rails-mailing-l...@andreas-s.net wrote: Hashes are not ordered in ruby 1.8 - if you want an ordering use an array (eg [['Yes', 1], ['No',0]]). For an option to be preselected it's value (the second bit) must be equal to the last

[Rails] parsing an xml file from another website

2009-02-21 Thread Scott Kulik
I'm using getclicky for my site statistics. They have a url I can use to get the number of users online. I found ways to parse an xml file if it is local, but how should i do this if is from another link like

[Rails] counting number of guests online

2009-02-18 Thread Scott Kulik
I'm currently using eldorado forum which shows the users that are currently logged on. I wanted to also add the number of guests that are currently viewing the site. What do you think is the best way to go about this and where should I keep track of this number? I'm thinking I would have to

[Rails] how to clear javascript cache on server

2009-02-17 Thread Scott Kulik
I just updated one of my javascript libraries and restarted the thin server but I can see the old javascript file is still being cached somehow. How can I fix this? I cleared my local cache as well but it is still pulling up the old javascript file. -- Posted via http://www.ruby-forum.com/.

[Rails] Re: how to clear javascript cache on server

2009-02-17 Thread Scott Kulik
Scott Kulik wrote: I just updated one of my javascript libraries and restarted the thin server but I can see the old javascript file is still being cached somehow. How can I fix this? I cleared my local cache as well but it is still pulling up the old javascript file. got it. i had

[Rails] sorting an array by mutliple fields

2009-01-29 Thread Scott Kulik
I can do sorting by a single field like the following: @users.sort! { |a,b| a.name.downcase = b.name.downcase } but what if i want to sort by user.name and then user.rank? what's the best way to do this? thanks! -- Posted via http://www.ruby-forum.com/.

[Rails] Re: sorting an array by mutliple fields

2009-01-29 Thread Scott Kulik
Scott Kulik wrote: I can do sorting by a single field like the following: @users.sort! { |a,b| a.name.downcase = b.name.downcase } but what if i want to sort by user.name and then user.rank? what's the best way to do this? thanks! just got it: @objects.sort! do |a,b| comp

[Rails] Re: collection_select and select_tag help

2009-01-02 Thread Scott Kulik
I have created the following select box which works fine except for the fact if you edit the item it defaults back to N/A instead of selecting the correct location. select_tag(item[location_id], 'option value=N/A/option' + options_for_select(@locations.collect{|location| [location.name,

[Rails] best way to store this data in the database

2009-01-02 Thread Scott Kulik
i have bunch of item properties that need to be stored in the database. the options for the properties are: -unknown -yes -no what do you think is the best way to store this data? should i use a tinyint and only store 0, 1, 2 for the respective options or just use a varchar(10) and store the

[Rails] changing row color on checkbox click

2008-12-29 Thread Scott Kulik
say for example i had something simple like this in a view: tr class=eventd%= check_box_tag(:task) %/td how would i add onclick to change the row color on a check and when the check is removed? maybe something like this? page[task].addClassName('complete') i'm not that familiar with

[Rails] Re: changing row color on checkbox click

2008-12-29 Thread Scott Kulik
Mark Reginald James wrote: Scott Kulik wrote: i'm not that familiar with javascript so i'm not sure how i would finish this. thanks! %= check_box_tag :task, 1, false, :onchange = $(parentNode.parentNode).toggleClassName('complete') % -- Rails Wheels - Find Plugins, List Sell

[Rails] Re: changing row color on checkbox click

2008-12-29 Thread Scott Kulik
Scott Kulik wrote: Mark Reginald James wrote: Scott Kulik wrote: i'm not that familiar with javascript so i'm not sure how i would finish this. thanks! %= check_box_tag :task, 1, false, :onchange = $(parentNode.parentNode).toggleClassName('complete') % -- Rails Wheels - Find

[Rails] Re: changing row color on checkbox click

2008-12-29 Thread Scott Kulik
Brandon Keepers wrote: On Mon, Dec 29, 2008 at 11:17 PM, Scott Kulik rails-mailing-l...@andreas-s.net wrote: another check box the first check box row gets highlighted. any idea what could be causing the incompatibility with IE? Try adding `this`: %= check_box_tag :task, 1, false

[Rails] Re: changing row color on checkbox click

2008-12-29 Thread Scott Kulik
Scott Kulik wrote: but they all produce the same weird result where they don't update until i click a second time. first click always does nothing. finally got it. it was the :onchange that was causing some issues. i changed it to :onclick and all methods are now working with IE7

[Rails] Re: help with counter_cache

2008-12-20 Thread Scott Kulik
Scott Kulik wrote: Scott Kulik wrote: Scott Kulik wrote: Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user

[Rails] Re: help with counter_cache

2008-12-19 Thread Scott Kulik
Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user. -- Posted via http://www.ruby-forum.com

[Rails] Re: help with counter_cache

2008-12-19 Thread Scott Kulik
Scott Kulik wrote: Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user. is there another i can do it like

[Rails] Re: help with counter_cache

2008-12-19 Thread Scott Kulik
Scott Kulik wrote: Scott Kulik wrote: Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user. is there another i

[Rails] Re: anyone know a good way to do a caption popup on mouseover?

2008-12-18 Thread Scott Kulik
Scott Kulik wrote: cool thanks i'll test it out this week! i just got it working. i like it because it's so simple but is there anyway to have the popup show up at the mouse pointer instead of a fixed location? i dont know javascript very well offhand. also, it looks like it's getting

[Rails] help with counter_cache

2008-12-18 Thread Scott Kulik
I have two models: Items -id -name -created_by (links to user id) ... Users -id -name -items_count ... item.rb: belongs_to :user, :class_name = 'User', :foreign_key = 'created_by', :counter_cache = true user.rb: has_many :items, :foreign_key = 'created_by'

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
bah...i figured it out. i didn't have a default value of 0 set in the field so it wasn't updating. now it's working! the only thing now is that i have a couple thousand users who have 0 for the count values. what do you think is the best way i can mass update this field? -- Posted via

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
Bryce Roney wrote: You can run a migration like this def self.up User.find(:all) do |u| u.update_attribute :items_count, s.items.count end end That will go through all your users and update the items_count field for all of them. ~~~ Bryce Roney [ twitter ][

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
Bryce Roney wrote: Oh sorry! I was copying the code out of a project I had. change s.items.count to u.items.count -- Bryce Roney np! i just tried it with the new code and it says its successful again but items_count is still showing 0. i checked @user.items.count in one of my views

[Rails] Re: anyone know a good way to do a caption popup on mouseover?

2008-12-18 Thread Scott Kulik
Emanuele Tozzato wrote: I did not try it on god-damn-IE.. =) you should modify the js part with code from this example http://www.codelifter.com/main/javascript/capturemouseposition1.html, the script was originally based on mouse position, but I thought it was annoying.. :) hmm...looks

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
Bryce Roney wrote: You can run a migration like this def self.up User.find(:all) do |u| u.update_attribute :items_count, s.items.count end end That will go through all your users and update the items_count field for all of them. ~~~ Bryce Roney [ twitter ][

[Rails] anyone know a good way to do a caption popup on mouseover?

2008-12-17 Thread Scott Kulik
I have been using overlib (javascript library) to create popups on mouseover but it has issues with some browsers. I just need something simple and was wondering if any had any suggestions. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You

[Rails] Re: thin server processes slowly growing in RAM size

2008-12-14 Thread Scott Kulik
Bobnation wrote: I would see if there are ways for you to implement caching ... but it also seems like there is maybe a memory leak within your code causing some problems. I'm not expert, but those are my thoughts. On Dec 9, 9:43�am, Scott Kulik rails-mailing-l...@andreas-s.net thanks

[Rails] Re: thin server processes slowly growing in RAM size

2008-12-12 Thread Scott Kulik
i guess nobody has as many problems as me. in general, do thin server processes normally keep growing and growing or do they cap out in size? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to

[Rails] thin server processes slowly growing in RAM size

2008-12-09 Thread Scott Kulik
When I initially start up my server I have two thin processes running that are only about 200M in size. They slowly creep up a few megs an hour until now a week later they are at 400M and 300M respectively. I realize that my site (http://wlodb.com) has some intensive pages that take a couple

[Rails] adding smileys to posts

2008-11-19 Thread Scott Kulik
i want to add a little side box next to the posts where users can click smiley icons to insert them into the post. i'm guessing that i'm probably going to use ajax/javascript but was wondering if there are some easier ways to do this with some built in rails functionality...or if there are

[Rails] Re: before_filter to restrict user from editing locked item

2008-11-10 Thread Scott Kulik
Frederick Cheung wrote: On Nov 10, 12:58�am, Scott Kulik [EMAIL PROTECTED] wrote: Frederick Cheung wrote: thanks for the info fred. i was just thinking that I should probably do the checking to see if an item is locked in the model before updating. �so in item.rb: Personally I would

[Rails] Re: toggle! not working

2008-11-10 Thread Scott Kulik
Elias Orozco wrote: Hi Scott, Try :put instead of :post on the :member param, like this: map.resources :compounds, :collection = { :calculator = :get }, :member = { :confirm = :put } Elias, i tried put but got this error back: Only put requests are allowed. robert, i think the

[Rails] Re: before_filter to restrict user from editing locked item

2008-11-09 Thread Scott Kulik
Frederick Cheung wrote: On 9 Nov 2008, at 20:19, Scott Kulik wrote: end Well you can't pass an argument to a filter like that. you'd have to fetch the item first (I presume this is all boilerplate stuff so you're interested in the one of id params[:id]. Also, returning false from

[Rails] before_filter to restrict user from editing locked item

2008-11-09 Thread Scott Kulik
I have a list of items in which some are locked. if they are locked then I want to make them not be able to be edited. how can i set up something like this: before_filter :locked?(item), :only = [:edit, :update] def locked?(item) if item.locked then return false end or how should i

[Rails] creating empty array of items - should be a quick simple one

2008-11-06 Thread Scott Kulik
here is some of the code: @items_all = Item.find(:all) for item in @items_all do if not FileTest.exist?(item.image_name) @items_missing_images += item end end You have a nil object when you didn't expect it! You might have expected an instance of Array. The

[Rails] Re: creating empty array of items - should be a quick simple one

2008-11-06 Thread Scott Kulik
thanks for both replies! that's exactly what i was looking for. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send

[Rails] fragment caching with search box

2008-10-02 Thread Scott Kulik
I'm trying to setup some fragment caching which works fine for the index but i'm not sure how to ignore the caching if they are searching the index results. my code in short: ItemsController def index @items = Item.search(params[:search], params[:min_rank], params[:max_rank],