[Rails] Re: Re: Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
Colin Law wrote in post #1181854: > On 2 March 2016 at 22:06, David Williamswrote: > Just to point out that the fundamental mistake you made here was > calling it @following_activities. If you had called it > @following_posts or something similar then you would probably fnot > have made the error. > For the future simple debugging can be achieved by inserting logger > output in the code at appropriate points, so for example if after the > line > <% @following_activities.each do |user| %> > you insert the line > logger.info "user = #{user.inspect}" > then the debug would be inserted into log/development.log which would > probably have enabled you to see the problem. > > Colin Yes, it was a fatal flaw in my naming convention that led to the confusion. 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/c63a9c31caba143e9487cf46270f3f1a%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Re: Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
On 2 March 2016 at 22:06, David Williamswrote: > Colin Law wrote in post #1181852: >> On 2 March 2016 at 21:43, David Williams wrote: >>> Iterating over the @following_activities instance variable is giving me >>> errors for user.avatar.url and user.post. I don't understand why it's >>> not collecting all of the information from the user object. >>> >>> <% if @following_activities.any? %> >>> <% @following_activities.each do |user| %> >> >> In the code you posted earlier the activities are Post objects not >> User objects. Possibly you want >> @following_activities.each do |post| >> and then post.user.photo etc >> >> Colin > > It's working now. Thank you and Mahcsig for helping me. Just to point out that the fundamental mistake you made here was calling it @following_activities. If you had called it @following_posts or something similar then you would probably fnot have made the error. For the future simple debugging can be achieved by inserting logger output in the code at appropriate points, so for example if after the line <% @following_activities.each do |user| %> you insert the line logger.info "user = #{user.inspect}" then the debug would be inserted into log/development.log which would probably have enabled you to see the problem. Colin > > -- > 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/7519ae9bd5b199cf223e513ad94674b4%40ruby-forum.com. > For more options, visit https://groups.google.com/d/optout. -- 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%3D0gLsvoS7f%2BcJm4qTK5mn_sfCmBw3_v7DiVZ2tPrYuG4gYeg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
Colin Law wrote in post #1181852: > On 2 March 2016 at 21:43, David Williamswrote: >> Iterating over the @following_activities instance variable is giving me >> errors for user.avatar.url and user.post. I don't understand why it's >> not collecting all of the information from the user object. >> >> <% if @following_activities.any? %> >> <% @following_activities.each do |user| %> > > In the code you posted earlier the activities are Post objects not > User objects. Possibly you want > @following_activities.each do |post| > and then post.user.photo etc > > Colin It's working now. Thank you and Mahcsig for helping me. -- 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/7519ae9bd5b199cf223e513ad94674b4%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
On 2 March 2016 at 21:43, David Williamswrote: > Iterating over the @following_activities instance variable is giving me > errors for user.avatar.url and user.post. I don't understand why it's > not collecting all of the information from the user object. > > <% if @following_activities.any? %> > <% @following_activities.each do |user| %> In the code you posted earlier the activities are Post objects not User objects. Possibly you want @following_activities.each do |post| and then post.user.photo etc Colin > <%= link_to(image_tag(user.avatar.url(:thumb), style: > 'text-decoration: none;', class: 'round-image-50-trendy-warrior'), > user_path(user)) %> > <%= user.post.username %> > <%= user.post.body %> > <%= image_tag(user.post.photo.url(:medium), style: '') %> > <% end %> > <% else %> > No new posts > <% 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/8a06021c43b603b07ed4c52ff1e36142%40ruby-forum.com. > For more options, visit https://groups.google.com/d/optout. -- 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%3D0gLs9R-Tp72ycO435b2N%2BvX_QNkRZ7QnXv%3DOYMJr564eQng%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] How to match a literal colon in a route
I did some digging on this, and I couldn't find a way to make this work with a literal in the route itself. Splatting works, though: get 'baz/*ark_tag/:id/bar' => 'welcome#index', constraints: { ark_tag: 'ark:' }, as: :ark will only match paths like "/baz/ark:/123/bar". It's a little fussy with URL helpers, as you need to always specify ark_tag or you'll get an error: ark_path(ark_tag: 'ark:', id: 1234) You'll probably want to define your own helpers that hide that. The other, bigger issue is the OTHER features of the ARK spec that are going to confuse & annoy the default URL parser. In particular: * the dot-separated components of VariantPath elements. The default Rails behavior appends a `.:format` optional parameter to the route. This *doesn't* allow further dots. * the `?` and `??` suffixes. The single question-mark, in particular, is only detectable if you check the original request URI in the Rack request. I'm also unsure how to talk the regular path helpers into producing a single-question-mark URL. If you're building an application which relies on complex routing of ARK URLs, you may want to consider writing your own Rack middleware to hijack the URL parsing process and transmute them into something more palatable to the existing router. --Matt Jones On Monday, 29 February 2016 20:21:19 UTC-5, Justin Coyne wrote: > > I'd certainly prefer not to, but it is prescribed by the ARK standard: > https://en.wikipedia.org/wiki/Archival_Resource_Key > > -Justin > > On Mon, Feb 29, 2016 at 5:45 PM, Hassan Schroeder> wrote: > >> On Mon, Feb 29, 2016 at 3:04 PM, digger250 > > wrote: >> > I'm trying to figure out how to escape a literal colon in the routes. >> If I >> > make a route like this: >> > >> > get '/thing:/:id' => 'things#show' >> > >> > then '/thing:/123' does not match on this route >> > >> > I've also tried '/thing\:/:id' and '/thing%3A/:id' none seem to work. >> > >> > Does anyone have any tips here? >> >> Yes - don't do that :-) >> >> See https://www.ietf.org/rfc/rfc1738.txt, specifically Section 2.2 on >> reserved characters. >> >> -- >> Hassan Schroeder hassan.s...@gmail.com >> >> http://about.me/hassanschroeder >> twitter: @hassan >> Consulting Availability : Silicon Valley or remote >> >> -- >> 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-ta...@googlegroups.com . >> To post to this group, send email to rubyonra...@googlegroups.com >> . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDceABV646sh%2BH5L4uWoW%3D1Scc2ucj6ta4tYLU_q8JmRg%40mail.gmail.com >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/397a0487-c884-4f32-93de-48972ea47424%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
Iterating over the @following_activities instance variable is giving me errors for user.avatar.url and user.post. I don't understand why it's not collecting all of the information from the user object. <% if @following_activities.any? %> <% @following_activities.each do |user| %> <%= link_to(image_tag(user.avatar.url(:thumb), style: 'text-decoration: none;', class: 'round-image-50-trendy-warrior'), user_path(user)) %> <%= user.post.username %> <%= user.post.body %> <%= image_tag(user.post.photo.url(:medium), style: '') %> <% end %> <% else %> No new posts <% 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/8a06021c43b603b07ed4c52ff1e36142%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
Colin Law wrote in post #1181847: > On 2 March 2016 at 18:47, David Williamswrote: >> Post.where(user_id:following_ids).order("created_at >> desc").paginate(page:params[:page]) > > Also, assuming that you have User has_many following_users and User > has_many posts then you should be able to say something like > User has_many following_posts through following_users ... > You will need a bit more on the end get it to work, not exactly sure > what you need there. Perhaps someone else will know exactly what you > need. Then you will be able to say > current_user.following_posts > to get all those posts. > > So you will be able to say > @following_activities = (current_user.posts + > current_user.following_posts).sort > > Colin Thanks for responding guys. Right now, I'm using the methods that are included with the Acts_As_Follower Gem. -- 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/46c7c09698ee08d433d2bf90bb299f27%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
Mahcsig wrote in post #1181846: > def feed > following_ids = current_user.following_users.map(&:id) > following_ids << current_user.id > @following_activities = > Post.where(user_id:following_ids).order("created_at > desc").paginate(page:params[:page]) > end > > > ~Mahcsig I'm getting an error for the user's avatar image. For whatever reason, it's not seeing the full user model with attributes included. I'm using Carrierwave btw. <%= link_to(image_tag(user.avatar.url(:thumb), style: 'text-decoration: none;', class: 'round-image-50'), user_path(user)) %> undefined method `avatar' for # But, I see that it is loading the information within the instance variables. -- 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/f244e1213dc6348c31ccc3a24b168f1c%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] How do I add my own posts plus following users post with Acts_As_Follower Rails 4
On 2 March 2016 at 18:47, David Williamswrote: > I've been trying to combine my own post with the users that I follow in > chronological order DESC. Can you help me build the proper query method > for it? > > > What I currently have is the code below > > def feed > following_ids = current_user.following_users.map(&:id) > @following_activities = > Post.where(user_id:following_ids).order("created_at > desc").paginate(page:params[:page]) I don't think you want paginate here, and since you are going to sort it again later there is no point sorting here either. > @following_activities << current_user.posts.order('created_at > desc').all You want + here not << as you just want to concatenate the arrays, then you will not need to flatten in the next line. Also no need to sort in line above > @following_activities = @following_activities.flatten.sort_by > {|post| post.created_at } > end As I said above, no need for the flatten Also, assuming that you have User has_many following_users and User has_many posts then you should be able to say something like User has_many following_posts through following_users ... You will need a bit more on the end get it to work, not exactly sure what you need there. Perhaps someone else will know exactly what you need. Then you will be able to say current_user.following_posts to get all those posts. So you will be able to say @following_activities = (current_user.posts + current_user.following_posts).sort Colin > > Feed.html.erb > <% if @following_activities.any? %> > <% @following_activities.each do |user| %> > <%= link_to(image_tag(user.avatar.url(:thumb), style: > 'text-decoration: none;', class: 'round-image-50-trendy-warrior'), > user_path(user)) %> > <%= user.post.username %> > <%= user.post.body %> > <%= image_tag(user.post.photo.url(:medium), style: '') %> > <% end %> > <% else %> > No new posts > <% end %> > > The approach that I'm using is not causing any server errors. But, I'm > not seeing the post that I've already created, they aren't being loaded. > > -- > 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/5317cf6d26c8523f7496dc2931f4d1a7%40ruby-forum.com. > For more options, visit https://groups.google.com/d/optout. -- 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%3D0gLt0JXpspH7JKbPN57yYHX8c%3DKS0rmEKjVt1Rh9Ou9%3Do%3DQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
def feed following_ids = current_user.following_users.map(&:id) following_ids << current_user.id @following_activities = Post.where(user_id:following_ids).order("created_at desc").paginate(page:params[:page]) end ~Mahcsig On Wed, Mar 2, 2016 at 1:04 PM, David Williamswrote: > Mahcsig wrote in post #1181844: > > How about just adding the current_user.id to the following_ids array? > > You > > could then pull all the posts in one shot, and remove the next two > > lines. > > > > ~Marc > > > > > > ~Mahcsig > > > > On Wed, Mar 2, 2016 at 10:47 AM, David Williams > > Can you write-out your approach to simplify/refactor the code above??? > > -- > 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/67d70c57c5bb3a1199f54378d53a9eee%40ruby-forum.com > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CANBna%3DB2AX2sXyCuZ_CjRZfJCOnX-DfX7yA1UfayNwOG%2BOieNg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: How do I add my own posts plus following users post with Acts_As_Follower Rails 4
Mahcsig wrote in post #1181844: > How about just adding the current_user.id to the following_ids array? > You > could then pull all the posts in one shot, and remove the next two > lines. > > ~Marc > > > ~Mahcsig > > On Wed, Mar 2, 2016 at 10:47 AM, David WilliamsCan you write-out your approach to simplify/refactor the code above??? -- 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/67d70c57c5bb3a1199f54378d53a9eee%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] How do I add my own posts plus following users post with Acts_As_Follower Rails 4
How about just adding the current_user.id to the following_ids array? You could then pull all the posts in one shot, and remove the next two lines. ~Marc ~Mahcsig On Wed, Mar 2, 2016 at 10:47 AM, David Williamswrote: > I've been trying to combine my own post with the users that I follow in > chronological order DESC. Can you help me build the proper query method > for it? > > > What I currently have is the code below > > def feed > following_ids = current_user.following_users.map(&:id) > @following_activities = > Post.where(user_id:following_ids).order("created_at > desc").paginate(page:params[:page]) > @following_activities << current_user.posts.order('created_at > desc').all > @following_activities = @following_activities.flatten.sort_by > {|post| post.created_at } > end > > Feed.html.erb > <% if @following_activities.any? %> > <% @following_activities.each do |user| %> > <%= link_to(image_tag(user.avatar.url(:thumb), style: > 'text-decoration: none;', class: 'round-image-50-trendy-warrior'), > user_path(user)) %> > <%= user.post.username %> > <%= user.post.body %> > <%= image_tag(user.post.photo.url(:medium), style: '') %> > <% end %> > <% else %> > No new posts > <% end %> > > The approach that I'm using is not causing any server errors. But, I'm > not seeing the post that I've already created, they aren't being loaded. > > -- > 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/5317cf6d26c8523f7496dc2931f4d1a7%40ruby-forum.com > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CANBna%3DANe41MpEMcJfctpJ8%2Bk4q0sm34YKk8MpHVYAhh4RK7QQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Quickly get a free and trusted SSL certificate for your domain
Hi! I've published a small app which makes it quite easy to get a free and trusted SSL certificate. The app is available at https://tlsify.herokuapp.com/. It's in an early stage so there are a lot of bugs but the main features should work if the request is done correctly. - Just insert your domain and your contact email and generate a certificate. - In the next step you have to prove that you are the owner of the domain. (Wait one or two minutes after you created the TXT record!) - Copy the certificates into .pem files. Have fun with your certificates! Bugs and feedback please to tob...@feistmantl.io! A lot features will probably follow! Cheers Tobias -- 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/c06152d2-77d6-430e-9405-ec419ebc6d10%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] How do I add my own posts plus following users post with Acts_As_Follower Rails 4
I've been trying to combine my own post with the users that I follow in chronological order DESC. Can you help me build the proper query method for it? What I currently have is the code below def feed following_ids = current_user.following_users.map(&:id) @following_activities = Post.where(user_id:following_ids).order("created_at desc").paginate(page:params[:page]) @following_activities << current_user.posts.order('created_at desc').all @following_activities = @following_activities.flatten.sort_by {|post| post.created_at } end Feed.html.erb <% if @following_activities.any? %> <% @following_activities.each do |user| %> <%= link_to(image_tag(user.avatar.url(:thumb), style: 'text-decoration: none;', class: 'round-image-50-trendy-warrior'), user_path(user)) %> <%= user.post.username %> <%= user.post.body %> <%= image_tag(user.post.photo.url(:medium), style: '') %> <% end %> <% else %> No new posts <% end %> The approach that I'm using is not causing any server errors. But, I'm not seeing the post that I've already created, they aren't being loaded. -- 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/5317cf6d26c8523f7496dc2931f4d1a7%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] (╯°□°)╯︵ ┻━┻ table_flipper gem
Hello everybody, Another useless gem (table_flipper) that prepends the table flipper (╯°□°)╯︵ ┻━┻ to exceptions is out there: https://github.com/iridakos/table_flipper -- 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/b582e4be-8ede-4b8f-9389-0a040adb160b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] adding descriptions to images displayed in bluimp image gallery
On Tuesday, 1 March 2016 18:07:51 UTC-5, fugee ohu wrote: > > > > On Monday, February 29, 2016 at 9:22:55 PM UTC-5, Walter Lee Davis wrote: >> >> >> > On Feb 29, 2016, at 8:39 PM, fugee ohuwrote: >> > >> > >> > >> > On Monday, February 29, 2016 at 9:39:28 AM UTC-5, Walter Lee Davis >> wrote: >> > >> > > On Feb 28, 2016, at 7:24 PM, fugee ohu wrote: >> > > >> > > >> > > >> > [snip] >> > >> > > > Here's the code they provide, I tried but it doesn't have any >> effect so far >> > > > >> > > > blueimp.Gallery( >> > > > document.getElementById('links'), >> > > > { >> > > > onslide: function (index, slide) { >> > > > var text = >> this.list[index].getAttribute('data-description'), >> > > >> > > For the preceding line to work, your element needs to have the >> attribute data-description on it. Does it? >> > > >> > > > node = this.container.find('.description'); >> > > >> > > For the preceding line to work, you need to have an empty HTML >> element with the classname description present in the page, within the >> container element of the slide (no clue where that means, I'm just >> interpreting the code for you). If that element exists, then it will be >> emptied and re-filled with the description. >> > > >> > > > node.empty(); >> > > > if (text) { >> > > > node[0].appendChild(document.createTextNode(text)); >> > > > } >> > > > } >> > > > } >> > > > ); >> > > >> > > My guess is that you are missing one or more of these antecedents, >> and without them, the JS won't have anything to work with. >> > > >> > > Walter >> > > >> > > >> > > hi, thanks, i dunno what you mean by an empty html element with the >> classname description, i think you mean but >> that's not my view Here's my view: >> > > >> > > >> > > >> > > <% @profile.pictures.in_groups_of(5, false) do |row_tasks| %> >> > > >> > ><% for task in row_tasks do %> >> > > <%= image_tag(task.name.thumb) %> >> > ><% end %> >> > > <% end %> >> > > >> > > >> > > >> > >> > Yes, you did get what I meant. Reading through the portion of the >> script you provided, I can't see where that element needs to be. Perhaps it >> is added by the lightbox code when it creates the overlay elements. In any >> case, you have added the correct data attributes to the link, so that part >> looks right. In the example for the gallery, was there any reference to >> creating a separate structure in the page html to receive the description? >> In the documentation, do they have an example page coded in HTML that >> includes a secondary overlay element or similar? Or is it all generated by >> the JS code when the page loads? >> > >> > Walter >> > >> > > >> > > -- >> > > 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-ta...@googlegroups.com. >> > > To post to this group, send email to rubyonra...@googlegroups.com. >> > > To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/ed810211-4222-4a87-978f-bf9942b78193%40googlegroups.com. >> >> >> > > For more options, visit https://groups.google.com/d/optout. >> > >> > >> > No, there isn't The docs are at >> https://github.com/blueimp/Gallery/blob/master/README.md#setup and the >> relevant section is headed Additional Gallery Elements about 3/4 of the way >> down ~ fugue >> >> Start here, and see that you do need to add a description element (empty) >> if you want it to be updated with the value you set in the data-description >> attribute. >> >> >> https://github.com/blueimp/Gallery/blob/master/README.md#additional-gallery-elements >> >> >> Walter >> >> > >> > -- >> > 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-ta...@googlegroups.com. >> > To post to this group, send email to rubyonra...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/ba8a9e19-aead-47d7-b7d1-0e516a6db7dc%40googlegroups.com. >> >> >> > For more options, visit https://groups.google.com/d/optout. >> >> > I still haven't gotten this working > Since it's still not working, I'd recommend you start checking things one-by-one to verify they are working as you expect. * does the gallery work *other* than the description field? Are there any errors / warnings in the browser console? If so, deal with those before moving on. * add a breakpoint inside the 'onslide' handler the documentation provides. Are things as expected? Are the "text" and "node" variables getting