How can I get the class name from an ActiveRecord object? I have: result = User.find(1) I tried: result.class # => User(id: integer, name: string ...) result.to_s # => #<User:0x3d07cdc>" I need only the class name, in a string (User in this case). Is there a method for that? I know this is pretty basic, but I searched both Rails' and Ruby's docs, and I couldn't find it.
I have an object Results that contains an array of result objects along with some cached statistics about the objects in the array. I'd like the Results object to be able to behave like an array. My first cut at this was to add methods like this def <<(val) @result_array << val end This feels very c-like and I know Ruby has better way. I'd also like to be able to do this Results.each do |result| r
Is it possible to check the overflow:auto of a div? For example: HTML <div id="my_div" style="width: 100px; height:100px; overflow:auto;" class="my_class"> * content </div> JQUERY $('.my_class').live('hover', function (event) { if (event.type == 'mouseenter') { if( ... if scrollbar visible ? ... ) { alert('true'): } else { alert('false'): } } }); Sometimes is the content short (no scrollbar) and s
I need to query comments made in one day. The field is part of the standard timestamps, is created_at. The selected date is coming from a date_select. How can I use ActiveRecord to do that? I need something like: "SELECT * FROM comments WHERE created_at BETWEEN '2010-02-03 00:00:00' AND '2010-02-03 23:59:59'"
I am using a gem which is in vendor/gems/some-api-0.1.0, copied over from another project, and added to Gemfile: gem 'some-api', :path => '~/development/myproj/vendor/gems/some-api-0.1.0' but if I do the following, it will fail with the message: $ bundle install Fetching source index for http://rubygems.org/ Could not find gem 'some-api (>= 0)' in source at ~/development/myproj/vendor/gems/some-ap
This works but gets stopped because it lacks an authenticity token: $(".ajax-referral").click(function(){ $.ajax({type: "POST", url: $(this).parent("form").attr("action"), dataType: "script"}); return false; }); So I tried adding it like so: $(".ajax-referral").click(function(){ $.ajax({type: "POST", url: $(this).parent("form").attr("action") + "?&authenticity_token=" + AUTH_TOKEN, dataType: "scri
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く