[Rails] Problem accessing paperclip file attributes in a callback (observer)

2009-09-28 Thread JL Smith
I'm having trouble accessing paperclip file attributes in an after_destroy callback on my attachment model. I can't seem to access the paperclip-managed attributes but I can access non-paperclip attributes. Here's an example: class AttachmentObserver < ActiveRecord::Observer def after_destroy

[Rails] Re: Problem with Double Submit

2009-09-05 Thread JL Smith
If I'm following you correctly, check out the RailsSpace book site. You can download the final application. In the application, look at the comments conroller in the create action. He's checking for duplicates and throwing them out if so. http://www.railsspace.com/ I hope that's what you meant

[Rails] Re: ActiveRecord doesn't care about timezone?

2009-09-05 Thread JL Smith
a mess on your > hands, as the two months where DST changes won't have a consistent > offset... > > --Matt Jones > > On Sep 3, 9:39 pm, JL Smith wrote: > > > Yeah, I tried that in my example that I posted but the results aren't > > then converted back to

[Rails] Re: ActiveRecord doesn't care about timezone?

2009-09-03 Thread JL Smith
, 11:54 am, Matt Jones wrote: > This looks like an instance of this bug: > > https://rails.lighthouseapp.com/projects/8994/tickets/2946 > > The quick way to fix it in this case is to convert the incoming > datetime objects to UTC in timeline_created_products. > > --Matt Jone

[Rails] Re: Thin controllers and fat models

2009-09-03 Thread JL Smith
You want the controller to responsible for passing model data from the database to the view and vice versa. You don't want to clutter the controller with model specific logic...that's why you want it in the model where it's self-contained. Try this article: http://www.therailsway.com/2007/6/1/r

[Rails] Re: What's the best way to install Rails? (on vista)

2009-09-03 Thread JL Smith
That logic applies to all the databases. The moment you use proprietary database functions in your SQL, you have just locked yourself in to using that database vendor. That same function may or may not exist with another database vendor. Not that it's a bad thing, just that your code is not dat

[Rails] Re: What's the best way to install Rails? (on vista)

2009-09-03 Thread JL Smith
Incompatible with production DB? Rails/ActiveRecord is database independent (as long as you aren't using proprietary functions in raw SQL queries). The code you wrote in development against a SQLite database will work with MySQL, Oracle, Postgresql, etc. in production with simply a change to dat

[Rails] Re: What's the best way to install Rails? (on vista)

2009-09-02 Thread JL Smith
I guess I didn't clarify that...I'm simply saying that I use SQLite for development because it's so lightweight and easy to setup. The firefox plugin is icing on the cake. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Grou

[Rails] Re: Using an IDE as just a text editor?

2009-09-02 Thread JL Smith
No, RubyMine is not free. But it's also not an editor, like KomodoEdit. KomodoEdit simply supports multiple languages for syntax highlighting and such. RubyMine was built specifically for the Rails framework, in addition to ruby of course. KomodoEdit knows nothing about Rails, not to my knowle

[Rails] Re: Using an IDE as just a text editor?

2009-09-02 Thread JL Smith
You have to create a new project using existing source. Just go through the new project wizard in either of those IDE's to create your new project, just using existing source code. But speaking of IDE's, if you haven't tried RubyMine, you're missing out. I've used both Aptana Radrails and Netbe

[Rails] Re: What's the best way to install Rails? (on vista)

2009-09-02 Thread JL Smith
And don't forget the SQLite Manager Firefox plugin: https://addons.mozilla.org/en-US/firefox/addon/5817 I used to be dead set on installing and developing on MySQL...no more of that. SQLite is too easy to work with...lightweight, no headaches. And the Firefox plugin is the complete interface t

[Rails] ActiveRecord doesn't care about timezone?

2009-09-02 Thread JL Smith
I'm having some trouble getting activerecord to adhere to my timezone settings when finding objects based on its created_at field. I understand that datetime fields are stored in UTC but it doesn't convert the datetimes when it performs the lookup. I basically followed Railscasts #106 and I'm us

[Rails] ActiveRecord finder using :group?

2009-08-31 Thread JL Smith
I'm trying to gather and display some simple statistical data. I want to display the number of Products created over the last month, grouped by the day they were created. Am I on the right track as far as the ActiveRecord finder and also how would I iterate over the results in the view to spit o

[Rails] Re: problem with links

2009-08-27 Thread JL Smith
Oh, and the links you posted in the first post don't specify a controller so it assumes those actions all belong to the current controller which obviously is not the case...so you need to add the site controller to the links: <%= link_to_unless_current "Help", :controller => 'site', :action => 'h

[Rails] Re: problem with links

2009-08-27 Thread JL Smith
The user controller needs to have the register action. Also run rake:routes to make sure you've got wired correctly. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group,

[Rails] Re: rails 3.0

2009-08-26 Thread JL Smith
Rails 3.0 is still in development so I doubt anyone has completed a book on it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@google

[Rails] Re: getting error NoMethodError in Book#new

2009-08-26 Thread JL Smith
Have you run all the necessary database migrations? Does the books table have the title and price columns? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send emai

[Rails] Re: f.select onchange determine other fields in view

2009-08-26 Thread JL Smith
Is this what you're trying to do? http://railscasts.com/episodes/88-dynamic-select-menus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t

[Rails] Re: Alphabetize pagination

2009-08-26 Thread JL Smith
And I also made it all work via ajax using this simple railscast: http://railscasts.com/episodes/174-pagination-with-ajax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this g

[Rails] Re: Alphabetize pagination

2009-08-26 Thread JL Smith
Here's how I implemented something similar. On the index page of my contacts, I list them alphabetically by default, paginated with 10 per page. At the top of this index page, I spit out the alphabet with each letter having it's own link. Click any letter and I return all the contacts whose las

[Rails] Re: Anything but Aptana

2009-08-26 Thread JL Smith
+1 for RubyMineworth way more than the $50 I spent on it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsu

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread JL Smith
They could have also hit the 'enter' key multiple times too, not clicking anything. But in either case, a small amount of javascript will prevent this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:

[Rails] Re: Adding database fields to get a total

2009-08-24 Thread JL Smith
I'd suggest keeping that logic in the model...maybe create a method on your model for getting "grand_total". This blog post should give you a better idea of why you'd want this kind of logic in the model: http://railstips.org/2008/12/30/move-it-to-the-model-and-use-tiny-methods --~--~-~-

[Rails] Re: Error while installing Rails using gem install rails

2009-08-18 Thread JL Smith
http://wiki.rubyonrails.org/getting-started/installation/windows --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To u

[Rails] Re: Picture upload

2009-08-17 Thread JL Smith
Since you're new to RoR, why not use a plugin like Paperclip? It does exactly what you're trying to do and much more...should save you a lot of time. http://www.thoughtbot.com/projects/paperclip http://railscasts.com/episodes/134-paperclip --~--~-~--~~~---~--~~ Y

[Rails] Re: rails form_for submit button

2009-08-17 Thread JL Smith
<%= chapter_form.submit "Create", :class => "my-css-button-class" -%> --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com

[Rails] Re: ajax with will_paginate

2009-08-17 Thread JL Smith
http://railscasts.com/episodes/174-pagination-with-ajax or http://asciicasts.com/episodes/174-pagination-with-ajax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group,

[Rails] Re: Show validation error messages from a nested model?

2009-08-11 Thread JL Smith
I see what you're saying. I need to redirect from comments controller right back to where I was (show action of movies controller). But with the render, how do I specify the id to the movie that I'm returning to? Thanks for the help. --~--~-~--~~~---~--~~ You rec

[Rails] Show validation error messages from a nested model?

2009-08-10 Thread JL Smith
I'm trying to get error messages from a child object to show up on the view page of the parent object. Line #7 of show view is what I'm trying to do. What am I missing? If I enter a comment that is less than 30 characters, I should see some validation errors, no? Thanks for any help. http://g

[Rails] Authlogic::How to access current user from within a cache sweeper?

2009-08-03 Thread JL Smith
So I'm trying to follow along in Chad Fowler's Rails Recipes (recipe #59, Keeping track of who did what) and I simply want to access the current user from within my cache sweeper. Normally you just reference @current_user but that doesn't seem to be the case here. In Chad's example, he calls con

[Rails] Re: continuous integration

2009-06-05 Thread JL Smith
Here's a couple of sites that show you what the "cool kids" are using...ruby-toolbox.com has a subsection on CI. http://ruby-toolbox.com/ http://rubytrends.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby

[Rails] Re: {ActionController] Default route naming

2009-06-05 Thread JL Smith
Looks fine to me...what are you expecting the route to be? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubsc

[Rails] Re: {ActionController] Default route naming

2009-06-05 Thread JL Smith
Are you talking about singular resources? http://guides.rails.info/routing.html#singular-resources If not, you may want to show how you're declaring your route... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby

[Rails] Re: Is this a use case for has_many :through?

2009-06-05 Thread JL Smith
Yeah, another user can update somebody's post but I don't think that even matters in this case (think of this as having multiple admins editing posts). The alerts table still needs to connect both the user and the post so that a user other than the user that created the post can enable an alert o

[Rails] Is this a use case for has_many :through?

2009-06-05 Thread JL Smith
I'm building a blog application that allows users to create and edit blog posts. I want to add the ability for a user to check a box on the post page that enables an alert on the post that sends an email to the user when the post is updated. I would think my alerts table would simply consist of

[Rails] Re: Use callbacks to determine model field changes?

2009-05-28 Thread JL Smith
Thanks for the help guys. However, I've now hit the trap where I need session data in the observer (who is changing the model)... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post t

[Rails] Re: Know what was updated

2009-05-28 Thread JL Smith
That's a great point Philip. I'm actually trying to solve that very problem in a project I'm working on. I want to be able to do exactly what lighthouseapp does when it logs ticket updates. In that case, you have comments that people can make on a ticket. But when someone updates the ticket, I

[Rails] Re: Know what was updated

2009-05-28 Thread JL Smith
First, get familiar with model callbacks if you're not already because you don't want to put this logic in the controller: http://guides.rails.info/activerecord_validations_callbacks.html#callbacks-overview Then check out the dirty object feature that ActiveRecord provides and how to use it: ht

[Rails] Re: how to create dependent record automatically

2009-05-28 Thread JL Smith
I would go with the observer so you can keep the logic in the model (observer)...skinny controllers, fat models and all. http://guides.rails.info/activerecord_validations_callbacks.html#observers --~--~-~--~~~---~--~~ You received this message because you are subsc

[Rails] Re: a way that helper functions not produce XHTML but HTML?

2009-05-27 Thread JL Smith
That's exactly why I'm saying not to waste your time...Rails lays it down in XHTML syntax so if he changed the doctype from XHTML specific, then his validation won't work. Hence, don't waste your time changing it if you're not worried about validation. On May 27, 3:27 pm, Hassan Schroeder wrot

[Rails] Re: a way that helper functions not produce XHTML but HTML?

2009-05-27 Thread JL Smith
Trying to change the way Rails lays down a stylesheet include is really a waste of time. This HTML vs XHTML syntax only matters if you're validating...otherwise, the browser renders it as HTML. Don't waste your time and definitely update your browser. --~--~-~--~~~---

[Rails] Use callbacks to determine model field changes?

2009-05-27 Thread JL Smith
What's the best way to examine what fields on a model are changing? Would you use a callback to do that and how? I guess the simplest example of this is how lighthouseapp documents changes that a person makes to a ticket: Milestone changed from “2.x” to “3.0” State changed from “new” to “open”

[Rails] Re: Problem installing latest ROR from scratch

2009-03-30 Thread JL Smith
Those instructions you linked to aren't platform specific. To install Rails on Windows, try the steps outlined in the first section of this article: http://www.smashingmagazine.com/2009/03/27/ultimate-beginners-guide-to-ruby-on-rails/ --~--~-~--~~~---~--~~ You rec

[Rails] Re: Two level Navigational menus

2009-03-30 Thread JL Smith
Why are you expecting a rails plugin to provide an xhtml navigation menu? Why not just implement the drop down menu using simply xhtml (lists) and css? Try this: http://www.lwis.net/free-css-drop-down-menu/ Specifically: http://www.lwis.net/free-css-drop-down-menu/dropdown.ultimate.linear.html

[Rails] Re: How to pull down menu

2009-03-27 Thread JL Smith
http://guides.rails.info/form_helpers.html#making-select-boxes-with-ease --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.

[Rails] Re: Helper

2009-03-23 Thread JL Smith
Another similar method... def show_flash [:notice, :warning, :message].collect do |key| content_tag(:div, flash[key], :class => "flash_#{key}") unless flash[key].blank? end.join end --~--~-~--~~~---~--~~ You received this message because you are subsc

[Rails] Re: Rails 2.3 Nested models

2009-03-22 Thread JL Smith
This should get you going...also check out the links at the end under "Resources". http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ru

[Rails] Re: Simple search form with restful routes?

2009-03-12 Thread Jl Smith
After updating my tickets resources in my routing config like Andrew suggested, does anyone know how I might pass the :id param to the show method from the new search method so I don't have to re-write the code in the show method? All I want to do is reuse the show method...it's doing exactly

[Rails] Re: Simple search form with restful routes?

2009-03-07 Thread JL Smith
named route is > doing. > > What you need is something like this: > > # tickets_controller > def search >   show > end > > # routes.rb > map.resources :tickets, :collection => { :search => :post } > > You can now GET or POST to /tickets/search or tick

[Rails] Simple search form with restful routes?

2009-03-06 Thread Jl Smith
What am I doing wrong? I just want to create a simple form where I can enter the ID of a model and it take me to that model. I'm trying to place the form in the application layout, so I can use it from anywhere in my app. I'm using restful routes only. I keep getting this routing error when tr

[Rails] Re: Should I get Agile Web Development with Rails (Pragmatic Programmers) Book?

2008-11-11 Thread JL Smith
Besides the example depot application, I can't imagine the book covering a great deal more than the new rails guides: http://guides.rubyonrails.org/ On Nov 11, 6:20 am, bena <[EMAIL PROTECTED]> wrote: > I'm an experienced programmer, working for a lot of years in the > industry, and have been l

[Rails] Re: text wrap

2008-11-06 Thread JL Smith
<%h f.body%> won't work? On Nov 5, 11:42 pm, "Ishara Gunathilake" <[EMAIL PROTECTED]> wrote: > i hav a this code > <%h f.body%> > which shows some texts which are retrieved from > a table..i want to wrap the texts,,i cant add div tag to > between that code. please can anyone help me to solve thi

[Rails] Re: active record associations

2008-11-06 Thread JL Smith
This sounds like the dirty object feature of Rails 2.1 would work great: http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects Maybe even try to utilize some callback methods so you can capture and display the changes to the user: http://railsforum.com/viewtopic.php?id=2

[Rails] Which is the best attachment plugin for my situation?

2008-11-05 Thread JL Smith
I'm trying to decide which attachment plugin best suites the needs for my project. I have a model that I want to associate one or many attachments to. The content-type of the attachment will vary as well (pdf, jpeg, doc, zip), not just an image type. Thanks for any help! --~--~-~--~