Re: [Rails] Re: Rails SQL query counts results when not asked

2016-08-25 Thread Bazley
Indeed. At least the misery of fixing this problem has given me a deeper understanding of Rails! -- 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 rubyonra

[Rails] Re: Rails SQL query counts results when not asked

2016-08-24 Thread Bazley
The first thing I do with it is this: if @new_relationships.any? So it looks like .any? affects the query? I would have thought rails would perform the query, get all the records into @new_relationships, and then count them. This is a surprising feature. -- You received this message because y

[Rails] Re: Rails SQL query counts results when not asked

2016-08-24 Thread Bazley
:54 PM UTC+1, Frederick Cheung wrote: > > > > On Wednesday, August 24, 2016 at 1:11:42 PM UTC+1, Bazley wrote: >> >> This rails/sql code... >> >> @new_relationships = User.select('*') >> .fro

[Rails] Re: Rails SQL query counts results when not asked

2016-08-24 Thread Bazley
The first thing I do with it is this: if @new_matches.any? On Wednesday, August 24, 2016 at 1:26:54 PM UTC+1, Frederick Cheung wrote: > > > > On Wednesday, August 24, 2016 at 1:11:42 PM UTC+1, Bazley wrote: >> >> This rails/sql code... >> >>

[Rails] Rails SQL query counts results when not asked

2016-08-24 Thread Bazley
This rails/sql code... @new_relationships = User.select('*') .from("(#{@rels_unordered.to_sql}) AS rels_unordered") .joins(" INNER JOIN relationships ON rels_unordered.id = rel

[Rails] Direct to S3 upload using aws-sdk gem and jQuery-File-Upload on heroku

2016-01-09 Thread Bazley
ct-to-s3-image-uploads-in-rails> instructions. This is the upload form produced in the html: https://websmash.s3.amazonaws.com"; data-host="websmash.s3.amazonaws.com" enctype="multipart/form-data" action="/users/bazley/update_pictures&quo

Re: [Rails] Rails 4 Error 422 on heroku with ajax button

2015-12-22 Thread Bazley
user; log delivery; Me; Bazley). Which of these represents "anyone signed in and using my website"? Secondly, what level of permissions should I give this group? (Read; Write; Read_ACP; Write_ACP) -- You received this message because you are subscribed to the Google Groups "Ruby

Re: [Rails] Rails 4 Error 422 on heroku with ajax button

2015-12-22 Thread Bazley
I apologise, I have been fiddling with my heroku apps. If you put the link straight into the browser you get this: https://websmash.s3.amazonaws.com/uploads/picturething/picture/5/baz1.jpg This XML file does not appear to have any style information associated with it. The document tree is shown

Re: [Rails] Rails 4 Error 422 on heroku with ajax button

2015-12-21 Thread Bazley
Update: Removing MiniMagick partially solves the problem - the ajax request goes through without error, returning this js: $('#profilepic').html('https://websmash.s3.amazonaws.com/uploads/picturething/picture/5/baz1.jpg\"; alt=\"baz1\" />') However the picture doesn't show up, there's jus

Re: [Rails] Rails 4 Error 422 on heroku with ajax button

2015-12-21 Thread Bazley
city_token=q7pjfNN0v6matLmOvEY6O78cZ20aZNf9bVnOerV38we0dU317%2BRUeeA0OOOdinBkhCFy9XkzWnPlf%2BRvX6Sj6w%3D%3D&callsign=bazley&picid=2" for ::1 at 2015-12-21 20:10:10 + Processing by PicturethingsController#update_profile as JS Parameters: {"authenticity_token"=> "q7pjfNN0

Re: [Rails] Rails 4 Error 422 on heroku with ajax button

2015-12-21 Thread Bazley
file_picture?authenticity_token=q7pjfNN0v6matLmOvEY6O78cZ20aZNf9bVnOerV38we0dU317%2BRUeeA0OOOdinBkhCFy9XkzWnPlf%2BRvX6Sj6w%3D%3D&callsign=bazley&picid=2" > for ::1 at 2015-12-21 20:10:10 + > > Processing by PicturethingsController#update_

[Rails] Re: Rails 4 Error 422 on heroku with ajax button

2015-12-21 Thread Bazley
city_token=q7pjfNN0v6matLmOvEY6O78cZ20aZNf9bVnOerV38we0dU317%2BRUeeA0OOOdinBkhCFy9XkzWnPlf%2BRvX6Sj6w%3D%3D&callsign=bazley&picid=2" for ::1 at 2015-12-21 20:10:10 + Processing by PicturethingsController#update_profile as JS Parameters: {"authenticity_token"=> "q7pjfNN0

[Rails] Rails 4 Error 422 on heroku with ajax button

2015-12-21 Thread Bazley
My Rails 4 app works fine locally but when I deploy to heroku I keep getting the error "422 Unprocessable Entity" for a particular ajax request: <%= button_to update_profile_picture_path( params: { picid:standardpicture.id, c

[Rails] Rails check partial is fully loaded following ajax call

2015-12-10 Thread Bazley
I render a partial after an ajax call: *show.js.erb* $("#notice_feed").html("<%=j render 'shared/notice_feed' %>") *_notice_feed.html.erb* <%= render @notices %> This ends up rendering a list of `@notices`. The names of each notice are listed on the right and I have some j

[Rails] Rails activerecord query counting records via has_many :through

2015-11-20 Thread Bazley
A character has_many :conversations, through: :chats, and each conversation has_many :characters, through: :chats. *character.rb* has_many :chats, foreign_key: "character_id", dependent: :destroy has_many :conversations, through: :chats, source: :conversation has_many :messages *con

[Rails] Rails leaflet map geosearch stopped working after precompiling assets

2015-10-21 Thread Bazley
I'm using meijer's geosearch in a leaflet map. It was working fine but I've suddenly broken it and I don't know how. The maps still appears, but the search box doen't appear in the map. The code that breaks the app is: new L.Control.GeoSearch({ provider: new L.GeoSearch.Provider.OpenSt

[Rails] Rails selecting record that has particular records through has_many association

2015-10-20 Thread Bazley
I've set up a messaging system between characters as follows. Each character `has_many :conversations` with other characters `through: :chat_groups`. Fairly standard setup I expect. character.rb has_many :chat_groups, class_name: "Chat", foreign_key: "character_id

[Rails] Re: Correct way to access nested parameters

2015-08-02 Thread Bazley
You were right, it looks like it's active_comment_relationship is nil, I think. I added the yaml line and got this: --- !ruby/hash:ActionController::Parameters utf8: ✓ authenticity_token: nNWNdGOzKSu5gfDkB4x3AFIO1PQnIggn65uE//SGQNzK8Ub5AOtsShH3CLZd+oU7ic9WlA+F0RbsSVR6X1I78w== callsign: bazzer

[Rails] Correct way to access nested parameters

2015-08-02 Thread Bazley
notice.rb: has_one :active_comment_relationship, class_name: "Commentrelationship", foreign_key: "commenter_id", dependent: :destroy has_one :supernotice, through: :active_comment_relationship, source: : commen

[Rails] Rails autosize plugin gem not working

2015-07-16 Thread Bazley
I'm having some issues getting Jack Moore's autosize plugin working in Rails 4. When I place the following script in `application.html.erb`, it doesn't work. But when I place it directly in the same view as the text area, it works fine. I thought all files could see the javascript if it was pla

[Rails] Active record duplication and save failure

2015-07-14 Thread Bazley
I have this error: `Errno::ENOENT in PicturethingsController#update_profile`. I'm trying to duplicate the standardpicture record and save that to @character.profilepicture. I also can't get @character.profilepicture to save to the database (I know from checking after entering the rails consol

Re: [Rails] Rails carrierwave has_many error

2015-07-10 Thread Bazley
Thank you Colin, that fixed it. I appreciate your help. The solution raises an interesting question, fully specified here on SO if you're interested: > > http://stackoverflow.com/questions/31306347/rails-carrierwave-has-many-error/31345762#31345762 > The question is, is a solution possible wi

[Rails] Rails carrierwave has_many error

2015-07-09 Thread Bazley
Each User has_one Character. Each Character has_one :profilepicture, of class Picturething, which holds a Carrierwave mount_uploader to upload a singe picture. Each Character has_many :standardpictures, also of class Picturething. Picture upload is handled in views/users/edit, which hits the up

[Rails] Re: Passing variable to partial failure

2015-06-28 Thread Bazley
Thank you all very much. I'm afraid the problem was me, being a moron. There's nothing wrong with the code. There was a second forgotten 'render' in view.html.erb causing the problem. Sorry. Thank you once again. -- You received this message because you are subscribed to the Google Groups "Ruby

[Rails] Re: Passing variable to partial failure

2015-06-28 Thread Bazley
Thank you very much for your help. Sorry, I should have included what's inside the block: it's a glyphicon block sign. I've researched the correct format for including a block (example here ), and I think I have

[Rails] Passing variable to partial failure

2015-06-27 Thread Bazley
In the view.html.erb: <%= render @posts %> In each _post.html.erb: <%= render partial: 'shared/block', locals: { blockedcallsign: post. callsign } %> In each _block.html.erb: <%= button_to blockrelationships_path, class: 'btn btn-default btn-xs', params: {

[Rails] Passing variable to partial failure

2015-06-27 Thread Bazley
In the view.html.erb: <%= render @posts %> In each _post.html.erb: <%= render partial: 'shared/block', locals: { blockedcallsign: post.callsign } %> In each _block.html.erb: <%= button_to blockrelationships_path, class: 'btn btn-default btn-xs', params: {

[Rails] Re: Rails Arel unit test error

2014-12-28 Thread Bazley
Sorry, line 11 is: self.create_character unless character # line 11 -- 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...@goog

[Rails] Rails Arel unit test error

2014-12-28 Thread Bazley
I have the following error: ERROR["test_character_should_be_valid", CharacterTest, 0.214787] test_character_should_be_valid#CharacterTest (0.21s)NoMethodError: NoMethodError: undefined method `val' for "$1":Arel::Nodes::BindParam app/models/user.rb:11:in `block in ' test/models/characte

[Rails] Rails unit test assert_template failure

2014-12-25 Thread Bazley
I have the following test: test/integration/authentication_test.rb: require 'test_helper' class AuthenticationTest < ActionDispatch::IntegrationTest def setup @admin = users(:barry) # grab user from fixtures end test "trying to view a user before logging in" do get user_path(@adm