[Rails] Re: Signature/Expires/Access Key ID appearing in URL Params aws paperclip
pls help me to find a better soln -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5237cd7854e2ca7a0e9010ec21bd6dbe%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: counting the result of a join (SOLVED)
The solution is found here: http://stackoverflow.com/questions/24607428/rubyonrails-counting-the-result-of-a-join Basically, I need to specify in my :dicts model, that there is an association to :cards # in class Dict: has_many :idioms, through: :cards After this, I can do: idioms.where(kind: kind).exists? -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ec99a75a5db0a6aba69f649ffbf01bba%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Heroku vs. local WEBrick: How could be this error be undetected?
It's 2.1.1p76 in both cases. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/aea8bab4984aeaac2e3e023ec99ba89b%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] STI where inheritance column values are not the same as the name of the class
I recently tried to retrofit STI on a database table that had already existed for a while. Here's a basic outline of the scenario. 1. I had a class 'Code' and a database table 'codes'. 2. 'Code' had an attribute 'units', which could be either '$' or '%' 3. I wanted the STI classes to be Code::Dollar or Code::Percent I successfully implemented this with the following: class Code self.inheritance_column = 'units' class << self def find_sti_class(units) unit_class_for[units] end def sti_name unit_class_for.invert[self] end def unit_class_for { '$' => Code::Dollar, '%' => Code::Percent } end end end This works perfectly if I use it in the following way: Code::Dollar.new(initialization_hash) Code::Percent.new(initialization_hash) However, if I do just Code.new(units: '$') or something.build(units: '$'), I get an error like the following: ActiveRecord::SubclassNotFound: Invalid single-table inheritance type: $ is not a subclass of Code What I really want is for Code.new(units: '$') to return me a Code::Dollar object. I was able to trace the lookup of the class name into ActiveRecord::Inheritance::ClassMethods#subclass_from_attrs. From there I could see that it was trying to build the class name from the units value in the database, which obviously doesn't work as there isn't a class named $ or %. What I'm really trying to do is setup STI to work correctly when the value of the database column doesn't correspond to a class name. As there is already another method called find_sti_class, it seems curious that we couldn't use it inside of subclass_from_attrs in order to make it work in this way. I did try it and was successful, but as find_sti_class is a private method, I did not submit a patch using this. So, after all of that, I guess what I'm after is finding out if doing such a thing is possible in Rails as is. If not, would a patch to make it possible be desired by people other than myself? And if that patch made find_sti_class part of the public interface, would that be likely to be accepted? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8af5104b-6e67-4dae-8e63-63216dcddccf%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: The user index does not display delete links
> The 'delete' link will be displayed ONLY if the current user (i.e. the > user > which is actually signe in) is ADMIN: > > if current_user.admin? > > So check the user credentials you use to sign in, - it is as easy as it > is. Yes, It's as easy as it is after you giving me direction. I solved this problem Thank you. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d1a726573f813d1c50b8d5321d17dd9e%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Signature/Expires/Access Key ID appearing in URL Params aws paperclip
s3 url that expires after 1 hr here is code file_name_in_s3 = "topic_alerts/"+report_name s3_config = YAML.load_file("#{Rails.root}/config/s3.yml") s3 = AWS::S3.new(:access_key_id => s3_config['development']['access_key_id'],:secret_access_key => s3_config['development']['secret_access_key']) bucket = s3.buckets[s3_config['development']['bucket']] object = bucket.objects[file_name_in_s3] s3_obj_url = object.url_for(:read,:authenticated => false,:response_content_disposition => "attachment") url generated is signed url and expires in one hr.. plshelp me to find a solutin to genrate public url with out parm values signature and expires -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3bbc3a0e74fd58e63668f48d6055064f%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: The user index does not display delete links
On Wednesday, July 9, 2014 7:02:09 AM UTC+2, Ruby-Forum.com User wrote: > > I am using Ruby 2.0.0 and Rails 4.0.5. I follow "Ruby on Rails tutorial > by Michael Hartl". > > I am trying to implement **"The destroy action"** (section 9.4.2). > > Administrative users should see delete link > > BUT > > When i sign in, delete link is not appear. I can't able to solve this > issue. > > Test suite run successfully. > > >>My application.js file contain: > > //= require jquery > //= require jquery_ujs > //= require turbolinks > //= require bootstrap > //= require_tree . > > >> _user.html.erb: > > > <%= gravatar_for user, size: 52 %> > <%= link_to user.name, user %> > <% if current_user.admin? && !current_user?(user) %> > | <%= link_to 'delete', user, method: :delete, > data: { confirm: "You sure?" } %> > <% end %> > > > I attache user_pages_spec.rb file. Please find it. > > How to fix this error? > > Kind regards > > Attachments: > http://www.ruby-forum.com/attachment/9872/user_pages_spec.rb > > > -- > Posted via http://www.ruby-forum.com/. > The 'delete' link will be displayed ONLY if the current user (i.e. the user which is actually signe in) is ADMIN: if current_user.admin? So check the user credentials you use to sign in, - it is as easy as it is. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4c9a34b9-8ed6-4897-89ec-b3a072c1f623%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: The user index does not display delete links
dasibre wrote in post #1151967: > If your tests are passing, try some debugging. > Check your current_user helper method make sure its working the way its > supposed to work. > > I would also check sessions to make sure the current user is available. I am providing sessions_helper: module SessionsHelper . . . . . def current_user=(user) @current_user = user end def current_user remember_token = User.digest(cookies[:remember_token]) @current_user ||= User.find_by(remember_token: remember_token) end def current_user?(user) user == current_user end . . . . . -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/dfd73281a1e1ccd27a497b6f0b4dbbd9%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: The user index does not display delete links
Serguei Cambour wrote in post #1152018: > On Wednesday, July 9, 2014 7:02:09 AM UTC+2, Ruby-Forum.com User wrote: >> When i sign in, delete link is not appear. I can't able to solve this >> //= require_tree . >> >> >> -- >> Posted via http://www.ruby-forum.com/. >> > > How do you sign in , - as admin or not ? That's the question :) No, First I will sign in. Then after sign in when i click on "Users". After then Page generate of "All users". In that page "Delete" link should appear BUT Delete link does not appear. How can I fix this problem? Kind regards. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/17ab5b28314e8737f10b0dd28211b1bc%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] paper clip aws s3
On 10 July 2014 10:38, Anu Sebastian wrote: > in application path public/users/user_list.csv is present. I need to > upload this CSV file to s3 . Now, in S3 it is storing as text file, not > as CSV. I am Using paperclip. > > file_to_s3 = File.open("public/users/user_list.csv") > CsvFileStorage.create!("csv" => file_to_s3) return report_name > > How can I read & convert this local CSV & upload it to s3. CSV files *are* just text files. Comma Separated Values in a text file. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLumuXcxd9A%2BVX1Mi0eDe_7YxBa_RnfRP7rgXthZ5YSNfg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] paper clip aws s3
in application path public/users/user_list.csv is present. I need to upload this CSV file to s3 . Now, in S3 it is storing as text file, not as CSV. I am Using paperclip. file_to_s3 = File.open("public/users/user_list.csv") CsvFileStorage.create!("csv" => file_to_s3) return report_name How can I read & convert this local CSV & upload it to s3. Please help. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0373d2128a407a45be57a78abc79cc19%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] how to achieve in rails way.?
On 9 July 2014 08:06, Darshan d wrote: > Hi all, > > i am a new rubiest. Started exploring rails recently. In that case work right through a good tutorial such as railsturial.org (which is free to use online) which will show you the basics of Rails. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvK7izt7bdKZg_VXJprT%2BaExXCVGTQqJggCn8cMHEk%3DKA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Client Side Validation gem - adding custom validator for select
Dear All, I have two select tags. Start time and end time select tag. I am using client side validation gem in the form. I need to check if the start time select tag has value less than the end time select tag, using a custom validator. Is there a way to achieve this in the client_side_validation gem. Or is there any other better way to do it. I need error message just like the client side validation gem. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/757d4e95-c588-41fc-b2e6-d5004d7bac1a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] how to achieve in rails way.?
Hi all, i am a new rubiest. Started exploring rails recently. Here is my problem i am trying to get objects from my custom database and render them as json objects. This is how tried. In my controller. def near begin @lat = params[:lat] @lon = params[:lon] @near_ids = [] def get_id(dist_var) @near_ids = Brand.find_by_sql("#Long query to find nearest stores around the given latlon ") puts 'Total id :'+@near_ids.length.to_s puts 'distance :'+dist_var.to_s end get_id(dist = 1) while(@near_ids.length < 10) dist +=5 get_id(dist) end @stores = [] @near_ids.each do |store| @stores << Store.find_by_id(store["id"]) end @user = @stores.paginate(:page => params[:page], :per_page => 10 ) rescue ActiveRecord::RecordNotFound render json: 'Not found', status: 404 end end But i know it is not the right way to do it in rails. how can i achieve this in rails way.? Mean using models how can i query my database to return the needed objects to my controller.? i use jbuilder to render returned id's as json. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/941eb57a-5026-4700-a480-0473bbfc7a79%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: The user index does not display delete links
On Wednesday, July 9, 2014 7:02:09 AM UTC+2, Ruby-Forum.com User wrote: > > I am using Ruby 2.0.0 and Rails 4.0.5. I follow "Ruby on Rails tutorial > by Michael Hartl". > > I am trying to implement **"The destroy action"** (section 9.4.2). > > Administrative users should see delete link > > BUT > > When i sign in, delete link is not appear. I can't able to solve this > issue. > > Test suite run successfully. > > >>My application.js file contain: > > //= require jquery > //= require jquery_ujs > //= require turbolinks > //= require bootstrap > //= require_tree . > > >> _user.html.erb: > > > <%= gravatar_for user, size: 52 %> > <%= link_to user.name, user %> > <% if current_user.admin? && !current_user?(user) %> > | <%= link_to 'delete', user, method: :delete, > data: { confirm: "You sure?" } %> > <% end %> > > > I attache user_pages_spec.rb file. Please find it. > > How to fix this error? > > Kind regards > > Attachments: > http://www.ruby-forum.com/attachment/9872/user_pages_spec.rb > > > -- > Posted via http://www.ruby-forum.com/. > How do you sign in , - as admin or not ? That's the question :) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5517f187-2a25-4a74-badb-052b649b09ca%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.