[Rails] Modelist gem now helps find path between ActiveRecord models and search by name/table/assoc/column

2013-06-28 Thread gsw
We have a complex legacy schema with a lot of tables and models, and I can't keep all of the paths between tables in my head, so just wrote something that could help find the path between any two models just by entering their model names like: bundle exec modelist paths my_model_1 my_model_2 w

Re: [Rails] Is command line Rails also so slow on Linuxes as it is on Windows?

2013-05-22 Thread gsw
To support what you are saying, there are newer faster versions of Ruby 2 for Windows as mentioned here: http://www.ruby-forum.com/topic/4411307 And Rails 4 is optimized for Ruby 2. It is also possible that if Windows is being run in a VM, that would be slower, or perhaps the hardware it is run

[Rails] Re: Creating nested hash from nested active record results

2013-05-22 Thread gsw
ullet On Wednesday, May 22, 2013 3:12:43 PM UTC-4, gsw wrote: > > Would this work? > > MyModel.last.serializable_hash methods: MyModel.reflections.keys > > Or is that too much? > > Look at the options that you can pass into serializable_hash. > > However, if you are doing

[Rails] Re: Creating nested hash from nested active record results

2013-05-22 Thread gsw
Would this work? MyModel.last.serializable_hash methods: MyModel.reflections.keys Or is that too much? Look at the options that you can pass into serializable_hash. However, if you are doing this for json/etc. serialization in the controller, check out ActiveModel::Serializers. On Wednesday,

[Rails] Re: Does anyone who USES Rails hate Rails?

2013-05-02 Thread gsw
On Thursday, May 2, 2013 5:19:17 AM UTC-4, Bigos wrote: > > I hate Rails sometimes. Now and then I have a feeling that using Rails is > like trying to fit a square peg in a round hole. For example Active record > doesn't fit my every need and sometimes I have to use SQL. Because I use > Rails I

[Rails] restful_json - implement declarative, featureful backend JSON services in Rails 3.1+, 4+ quickly

2013-03-19 Thread gsw
Hey, We've been using this for a while in production and just made some security fixes today and added it to Rubygems: https://github.com/rubyservices/restful_json Just: gem 'restful_json' and follow the directions in the README (it GitHub link above). It should work with Rails 3.1+ and 4+ (

[Rails] Re: autolog: easily debug-like logging on the fly in your Rails app

2012-10-19 Thread gsw
://github.com/garysweaver/autolog On Thursday, October 18, 2012 3:51:01 PM UTC-4, gsw wrote: > > Gem changed a lot from yesterday. It's a little more like Tracer now: > https://github.com/garysweaver/autolog > > On Wednesday, October 17, 2012 2:32:47 PM UTC-4, gsw wrote: >

[Rails] unexpected return (LocalJumpError) only when executing this code within autoloaded classes?

2012-10-18 Thread gsw
Posted on stackoverflow but no traction yet: http://stackoverflow.com/questions/12942505/why-does-using-set-trace-func-work-in-some-places-but-cause-unexpected-return-l The following is a generified part of the code in a gem I'm working on: module SomeModule class << self attr_a

[Rails] Re: autolog: easily debug-like logging on the fly in your Rails app

2012-10-18 Thread gsw
Gem changed a lot from yesterday. It's a little more like Tracer now: https://github.com/garysweaver/autolog On Wednesday, October 17, 2012 2:32:47 PM UTC-4, gsw wrote: > > If it helps anyone developing Rails apps or gems, I wrote a shortcut for > set_trace_func, so next time yo

[Rails] autolog: easily debug-like logging on the fly in your Rails app

2012-10-17 Thread gsw
If it helps anyone developing Rails apps or gems, I wrote a shortcut for set_trace_func, so next time you want to just add a line before and after some function you are trying to debug you can have Ruby temporarily output every line, method, etc. executed. Also, it lets you define the format, us

Re: [Rails] New in town

2012-10-05 Thread gsw
mmunity that > are worth a look. > > I'm coming from a ColdFusion background and enjoy reading blogs like > Raymond Camden's and Ben Nadal's where they regularly posts how too's and > ask Ray/Ben type things. > > Thanks, Richard > > > On Friday, 5 O

Re: [Rails] New in town

2012-10-05 Thread gsw
Yes, and that will be the same for railscasts, peepcode, and everything else. Things change quickly. But agree- I used to work somewhere that had access to Lynda and when I checked it their stuff was older, but like anything, maybe they have new content by the time you read this. On Friday, Oct

[Rails] Re: New in town

2012-10-05 Thread gsw
Online there is: http://guides.rubyonrails.org/ http://railscasts.com/ (but many not free, but worth it) https://peepcode.com/ (not free, but worth it) Most of what you run into you'll be able to google but note that things changed significantly from Rails 2 to 3 (and a lot between 3 and 3.1), a

[Rails] Re: Can I have Ruby on Rails without json

2012-10-02 Thread gsw
What is the error you are getting? You'd be better off leaving json in there. If you are looking for something more lightweight, have you also looked at Sinatra, etc.? http://www.sinatrarb.com/ On Tuesday, October 2, 2012 8:01:27 AM UTC-4, roelof wrote: > > Nobody who can tell me ? > > Op maand

Re: [Rails] RVM settings lost after every logout

2012-10-01 Thread gsw
Something else to consider is whether you are running the config that you assume that you are. Trying putting an echo into the startup script that contains the RVM setup, like "getting ready to load RVM...", then look into what shell you are using, which script is being used depending on whethe

[Rails] Re: How to Include Associations in #as_json

2012-09-28 Thread gsw
to_json and as_json are not what you are probably looking for. If you are using a decently up-to-date version of Rails, look at: https://github.com/josevalim/active_model_serializers That is what is going to be used in Rails 4. If you want Hypermedia (links to resources, etc.), HAL support, etc

[Rails] Re: Best way to hook into class_attribute setter?

2012-09-28 Thread gsw
;bar' puts "self.class.foobar=#{self.class.foobar}" end def index puts 'index called' end end end On Friday, September 28, 2012 11:03:02 AM UTC-4, gsw wrote: > > I have some class attributes that I'm setting in an ActiveSupport::Concer

[Rails] Best way to hook into class_attribute setter?

2012-09-28 Thread gsw
I have some class attributes that I'm setting in an ActiveSupport::Concern and would like to hook into class_attribute setters, but is really isn't acting like I would assume. Here's what I did to test. I didn't create a different controller, because just wanted to try to do as little as possib

[Rails] Re: A super-easy and great way to implement Gem configuration

2012-09-27 Thread gsw
t; 'value'} def self.time; Time.now; end end Posted here with more examples: http://stufftohelpyouout.blogspot.com/2012/09/forget-struct-and-openstruct-flexible.html On Sunday, September 23, 2012 11:56:49 AM UTC-4, gsw wrote: > > On Sunday, September 23, 2012 8:11:43 AM UTC-4, I

[Rails] Re: A super-easy and great way to implement Gem configuration

2012-09-23 Thread gsw
On Sunday, September 23, 2012 8:11:43 AM UTC-4, Ilia Bylich wrote: > > I am not sure that this way is simple. I usually use for gem configuration > this code > > require 'active_support/configurable' > module GemModule > include ActiveSupport::Configurable > > class << self > def setup >

[Rails] A super-easy and great way to implement Gem configuration

2012-09-22 Thread gsw
Just did this in my constance gem, and totally love it as a way to add configuration or options configurability to your gem: http://stufftohelpyouout.blogspot.com/2012/09/forget-struct-and-openstruct-flexible.html like: module MyModule class << self attr_accessor :debug, :proc, :some_mappi

[Rails] Re: "best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.

2012-09-19 Thread gsw
On Tuesday, September 18, 2012 12:28:00 PM UTC-4, gsw wrote: > > # I have not tested this- just a possibility of something that would use > roar-rails which provides consume! and deserialization. > def create > # another method to implement that relies on proper authori

[Rails] Re: "best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.

2012-09-18 Thread gsw
On Tuesday, September 18, 2012 12:28:00 PM UTC-4, gsw wrote: > > respond_with(errors: [@company.errors], location: users_url, > status: unprocessable_entity) > > Sorry, a lot of status symbols missing the preceding colon. Also, I think the location only needs to be set

[Rails] Re: "best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.

2012-09-18 Thread gsw
On Tuesday, September 18, 2012 12:28:00 PM UTC-4, gsw wrote: > respond_with(errors: [@company.errors], location: users_url, > status: unprocessable_entity) > > Ugh. Didn't need the array around @company.errors either. respond_with(errors: @company.errors, lo

[Rails] Re: "best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.

2012-09-18 Thread gsw
On Tuesday, September 18, 2012 12:28:00 PM UTC-4, gsw wrote: > rescue > puts $!.inspect, $@ > # TODO: add support for other formats > respond_to do |format| > format.json { render json: {errors: [$!.message]}, status: > (:internal_server_er

[Rails] "best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.

2012-09-18 Thread gsw
I've been writing a gem to implement and extend common controller functionality so that Rails can be used with Javascript frameworks like AngularJS (which we are using), Ember.js, etc. in such a way that the user doesn't have to tweak a a bunch of rails g controller boilerplate code to provide

[Rails] Re: ActiveRecord concurrency issue getting next sequence value and inserting record

2011-09-02 Thread gsw
Was just reminded that when select foobars_seq.nextval id from dual is called it should increment sequence number, and it does this even within transaction without rollback of the sequence number, so in theory it should not be reusing the same id gotten from the sequence since there should be no wa

[Rails] ActiveRecord concurrency issue getting next sequence value and inserting record

2011-09-02 Thread gsw
Have an app using an old version of Rails (2.3.2). There are a handful of servers running the application (and other applications) in passenger. When a model is added at the same time on two servers, sometimes one model that was just added by a user on the first server causes another comment being

[Rails] :has_many and :controller specified in routes.rb

2010-03-23 Thread gsw
Have an app using older version of Rails (2.3.2) that I need some routing assistance with if anyone has a minute. The app was originally designed to be purely html view, and an xml and json api was hacked on. To keep it clean, we are now moving the first version of the api (v1) under its own direc