<table-plus> order columns

74 views
Skip to first unread message

tomkins

unread,
Jul 23, 2012, 11:18:21 AM7/23/12
to hobo...@googlegroups.com
I have a table plus with fields that I can order, using:  :order_by => parse_sort_param(:name, num)
How can I do this for something like :company.contact so it would be :order_by => parse_sort_param(:name, num, company.contact)
This gives an error when I navigate to the page the table is on.
Thanks.

Bryan Larsen

unread,
Jul 23, 2012, 11:29:46 AM7/23/12
to hobo...@googlegroups.com
Are you using 1.4.0.pre7? If so, that should actually work as is.

If you can't switch to 1.4.0.pre7, you can do something like:

if parse_sort_param('user', 'user.email_address')
db_sort_field = {
"user" => "users.last_name",
"user.email_address" => "users.email_address",
}[@sort_field]
order_by=[db_sort_field, @sort_direction]
else
order_by=["users.last_name", "asc"]
@sort_field = "user"
@sort_direction = "asc"
end

then use :order_by => order_by

Bryan
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/3cHHSq7XHjYJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

tomkins

unread,
Jul 24, 2012, 4:59:48 AM7/24/12
to hobo...@googlegroups.com
Thank you but I'm new to rails and hobo and I don't understand how to implement your example. Could you show me more maybe using what I have so far?
I've highlighted the problem area:  
            
       hobo_index Lead.active.apply_scopes(:search   => [params[:search], :name, :state],
      :order_by => parse_sort_param(:name,:bu,:probability,:teamsize,:duration,:created_at,:decision_date,:state,:contact.company),
      :user_is => current_user,
      :bu_is => params[:bu])

On Monday, July 23, 2012 4:29:46 PM UTC+1, Bryan Larsen wrote:
Are you using 1.4.0.pre7?  If so, that should actually work as is.

If you can't switch to 1.4.0.pre7, you can do something like:

    if parse_sort_param('user', 'user.email_address')
      db_sort_field = {
        "user" => "users.last_name",
        "user.email_address" => "users.email_address",
      }[@sort_field]
      order_by=[db_sort_field, @sort_direction]
    else
      order_by=["users.last_name", "asc"]
      @sort_field = "user"
      @sort_direction = "asc"
    end

then use :order_by => order_by

Bryan

On Mon, Jul 23, 2012 at 11:18 AM, tomkins wrote:
> I have a table plus with fields that I can order, using:  :order_by =>
> parse_sort_param(:name, num)
> How can I do this for something like :company.contact so it would be
> :order_by => parse_sort_param(:name, num, company.contact)
> This gives an error when I navigate to the page the table is on.
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/3cHHSq7XHjYJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+unsubscribe@googlegroups.com.

Matt Jones

unread,
Jul 24, 2012, 7:27:10 AM7/24/12
to hobo...@googlegroups.com

On Jul 24, 2012, at 4:59 AM, tomkins wrote:

> Thank you but I'm new to rails and hobo and I don't understand how to implement your example. Could you show me more maybe using what I have so far?
> I've highlighted the problem area:
>
> hobo_index Lead.active.apply_scopes(:search => [params[:search], :name, :state],
> :order_by => parse_sort_param(:name,:bu,:probability,:teamsize,:duration,:created_at,:decision_date,:state,:contact.company),

This is a Ruby gotcha - if you're going to put anything outside of [a-zA-Z0-9_] in a symbol value, you need to quote it:

:'contact.company'

--Matt Jones


tomkins

unread,
Jul 24, 2012, 7:48:41 AM7/24/12
to hobo...@googlegroups.com
That does not work, makes the whole page error.

Matt Jones

unread,
Jul 24, 2012, 8:14:35 AM7/24/12
to hobo...@googlegroups.com

On Jul 24, 2012, at 7:48 AM, tomkins wrote:

> That does not work, makes the whole page error.

OK, then can you post the actual error + stacktrace? Remote debugging is tricky, but *psychic* remote debugging is downright tough...

--Matt Jones

tomkins

unread,
Jul 24, 2012, 8:56:31 AM7/24/12
to hobo...@googlegroups.com
Like I say I'm new to rails and I don't know how to get the actual error or stacktrace. Our site uses its own error screen so it just says something went wrong. 

Matt Jones

unread,
Jul 24, 2012, 6:06:13 PM7/24/12
to hobo...@googlegroups.com

On Jul 24, 2012, at 8:56 AM, tomkins wrote:

> Like I say I'm new to rails and I don't know how to get the actual error or stacktrace. Our site uses its own error screen so it just says something went wrong.

Wait - are you debugging this on a production server? :(

If so, then step 1 is definitely "get this running in development mode locally". In dev mode, a crash will show a page detailing exactly what went wrong and where. It's not always easy to read those traces at first, but they're incredibly helpful when requesting help over mailing lists.

If the custom error page is still coming up in development mode, first sack whoever's responsible for that idea. (joking)

In all seriousness, if you *must* debug in production you should be able to find a stacktrace in log/production.log.

--Matt Jones


tomkins

unread,
Jul 25, 2012, 4:50:15 AM7/25/12
to hobo...@googlegroups.com
Thats right, its deployed on Heroku.
The only thing I see in log/ is passenger.3000.log, and it does not contain any recent information.
And yes, I always get the custom error page :(
Bryan, It would be greatly appreciated if you could expand on your example using the code I'm using? I can't find any similar situations to learn from.

Tomkins.

Raphael Sofaer

unread,
Jul 25, 2012, 11:03:23 AM7/25/12
to hobo...@googlegroups.com
If you're running on Heroku, you should be able to use "heroku log" to
get your logs. I think that's the command. Then do your bad request
and it will come up in the tail that Heroku gives you. A Heroku app
always logs to stdout, so there won't be any files.
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/IqMzBd1Wmy8J.
>
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
Message has been deleted

kevinpfromnm

unread,
Jul 25, 2012, 12:39:47 PM7/25/12
to hobo...@googlegroups.com
+1 for get it running on local dev box.  heroku is nice but the logs leave much to be desired when comes to debugging.  you have to have a copy of the code already, it's just a matter of setting up rvm or something to get a rails/hobo environment up.

On Wednesday, July 25, 2012 9:30:45 AM UTC-6, tomkins wrote:
Matt- I'm trying :'contact.company' again and when I click on the header of the column I want to order I don't get an error anymore but I also don't get the arrow and it doesn't order.


tomkins

unread,
Jul 26, 2012, 7:42:57 AM7/26/12
to hobo...@googlegroups.com
Error from logs: 

2012-07-26T11:36:48+00:00 heroku[nginx]: 127.0.0.1 - - [26/Jul/2012:11:36:48 +0000] "GET /leads?sort=contact.company HTTP/1.0" 500 948 "myherokusite.com/leads?sort=name" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.56.5 (KHTML, like Gecko) Version/5.1.6 Safari/534.56.5" myherokusite.com

2012-07-26T11:36:48+00:00 app[web.1]:   /home/heroku_rack/lib/static_assets.rb:9:in `call'

2012-07-26T11:36:48+00:00 app[web.1]:   /home/heroku_rack/lib/last_access.rb:15:in `call'

2012-07-26T11:36:48+00:00 app[web.1]:   /home/heroku_rack/lib/date_header.rb:14:in `call'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/connection.rb:76:in `pre_process'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/connection.rb:74:in `catch'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/connection.rb:74:in `pre_process'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/connection.rb:57:in `process'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/connection.rb:42:in `receive_data'

2012-07-26T11:36:48+00:00 app[web.1]:   eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'

2012-07-26T11:36:48+00:00 app[web.1]:   eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/backends/base.rb:57:in `start'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/server.rb:156:in `start'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/controllers/controller.rb:80:in `start'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/runner.rb:177:in `send'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/runner.rb:177:in `run_command'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) lib/thin/runner.rb:143:in `run!'

2012-07-26T11:36:48+00:00 app[web.1]:   thin (1.2.6) bin/thin:6

2012-07-26T11:36:48+00:00 app[web.1]:   /usr/ruby1.8.7/bin/thin:19:in `load'

2012-07-26T11:36:48+00:00 app[web.1]:   /usr/ruby1.8.7/bin/thin:19

2012-07-26T11:36:48+00:00 app[web.1]: 

2012-07-26T11:36:48+00:00 app[web.1]: 

2012-07-26T11:36:48+00:00 app[web.1]: Rendering /app/public/500.html (500 Internal Server Error)


Reply all
Reply to author
Forward
0 new messages