My rails controller didn't work - ruby-on-rails

My rails application is used acts-as-taggable-on. I would like to add function which articles can be searched by tags.
In my articles_controller.rb
def index
#articles = params[:tag].present? ? Article.tagged_with(params[:tag]) : Article.all
#articles = #articles.includes(:tags)
#articles = Article.page(params[:page])
end
In index.html.erb
<%= render partial:'tags',locals:{tags: article.tags}%>
In _tags.html.erb
<% tags.each do |tag| %>
<%= link_to "#{tag.name} (#{tag.taggings_count})", articles_path(tag: tag.name) %>
<%end%>
However, article wasn't scoped by tags. I confirmed that acts-as-taggable-on is working. Only tagged_with method doesn't work.
If you know any solution, please tell me.
In Active record
irb(main):001:0> Article.tagged_with("アップルパイ")
ActsAsTaggableOn::Tag Load (25.9ms) SELECT "tags".* FROM "tags" WHERE (LOWER(name) = LOWER('アップルパイ'))
Article Load (2.6ms) SELECT "articles".* FROM "articles" JOIN taggings articles_taggings_2902983 ON articles_taggings_2902983.taggable_id = articles.id AND articles_taggings_2902983.taggable_type = 'Article' AND articles_taggings_2902983.tag_id = 2
=> #<ActiveRecord::Relation [#<Article id: 6, title: "横浜のアップルパイ専門店", content: "横浜の赤レンガ倉庫にオープンしたアップルパイ専門のお店。写真のラズベリーソースは人気の味", created_at: "2017ge: "ras.jpg">, #<Article id: 18, title: "tagfie", content: "タグの機能を修理するためのテスト記事です。", created_at: "2017-04-05 15:41:23", updated_at: "2017-04-05 16:48:39", image: nil>, #<Article pie", content: "Apple pieの記事です", created_at: "2017-04-09 10:36:38", updated_at: "2017-04-09 10:36:38", image: nil>]>
irb(main):002:0>
However, by rails s
ActiveRecord::SchemaMigration Load (2.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <class:ApplicationController> at /Users/futamidaiki/Desktop/lablab/choco/app/controllers/application_controller.rb:2)
Processing by ArticlesController#index as HTML
Parameters: {"tag"=>"アップルパイ"}
ActsAsTaggableOn::Tag Load (5.8ms) SELECT "tags".* FROM "tags" WHERE (LOWER(name) = LOWER('アップルパイ'))
Rendering articles/index.html.erb within layouts/application
Article Load (2.7ms) SELECT "articles".* FROM "articles" LIMIT ? OFFSET ? [["LIMIT", 10], ["OFFSET", 0]]
ActsAsTaggableOn::Tag Load (3.7ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 5], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (7.8ms)
User Load (3.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 2], ["LIMIT", 1]]
ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 6], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (2.4ms)
ActsAsTaggableOn::Tag Load (0.5ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 7], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (2.8ms)
ActsAsTaggableOn::Tag Load (0.3ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 8], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (2.3ms)
ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 10], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (1.7ms)
ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 11], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (1.4ms)
ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 18], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (1.8ms)
ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 19], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (1.7ms)
ActsAsTaggableOn::Tag Load (0.3ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 20], ["taggable_type", "Article"], ["context", "tags"]]
Rendered articles/_tags.html.erb (1.8ms)
(0.2ms) SELECT COUNT(*) FROM "articles"
Rendered articles/index.html.erb within layouts/application (1827.4ms)
ActsAsTaggableOn::Tag Load (0.5ms) SELECT "tags".* FROM "tags" WHERE (LOWER(name) = LOWER('渋谷'))
ActsAsTaggableOn::Tag Load (0.3ms) SELECT "tags".* FROM "tags" WHERE (LOWER(name) = LOWER('表参道'))
ActsAsTaggableOn::Tag Load (0.3ms) SELECT "tags".* FROM "tags" WHERE (LOWER(name) = LOWER('青山'))
ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" WHERE (LOWER(name) = LOWER('横浜'))
ActsAsTaggableOn::Tag Load (0.3ms) SELECT "tags".* FROM "tags" WHERE (LOWER(name) = LOWER('その他'))
Completed 200 OK in 3143ms (Views: 2865.4ms | ActiveRecord: 21.7ms)

It looks like you are reassigning #articles in your controller to use pagination, which is overwriting .includes from the previous line. Try:
def index
articles = params[:tag].present? ? Article.tagged_with(params[:tag]) : Article.all
articles = articles.includes(:tags)
#articles = articles.page(params[:page])
end

Related

Acts-as-Taggable-On showing hash object instead of tag names

Acts-as-Taggable-on is failing to correctly print out only the name column, and not the entire hash of information on the object itself. How can I setup the show page to print out each tag separately for the model? The code that I have so far is below.
show.html.erb
<%= #user.user_profile.tags.each do |tag| %>
<%= tag.name %>
<% end %>
results shown on show page
#<ActsAsTaggableOn::Tag::ActiveRecord_Associations_CollectionProxy:0x2b7534d0> games [#<ActsAsTaggableOn::Tag id: 1, name: "games", created_at: "2017-08-25 15:54:30", updated_at: "2017-08-25 15:54:30", taggings_count: 1>] 1
console output
Rendering users/show.html.erb within layouts/application
UserProfile Load (8.0ms) SELECT "user_profiles".* FROM "user_profiles" WHERE "user_profiles"."user_id" = $1 LIMIT $2 [["user_id", 5], ["LIMIT", 1]]
ActsAsTaggableOn::Tag Load (15.0ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND "taggings"."context" = $3 [["taggable_id", 2], ["taggable_type", "UserProfile"], ["context", "tags"]]
ActsAsTaggableOn::Tagging Load (2.0ms) SELECT "taggings".* FROM "taggings" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 [["taggable_id", 2], ["taggable_type", "UserProfile"]]
ActsAsTaggableOn::Tag Load (25.0ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL) [["taggable_id", 2], ["taggable_type", "UserProfile"]]
user_profile.rb
class UserProfile < ApplicationRecord
acts_as_taggable
acts_as_taggable_on :abilities
end
Try
<% #user.user_profile.tags.each do |tag| %>
<%= tag.name %>
<% end %>
(without '=' after the '<%' in the first line)

Rails: Rolify gem not updating the database

So here's is what I did:
Select the user:
>> user = User.find(337633)
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 337633], ["LIMIT", 1]]
#<User id: 337633, name: "Restaurant Guy", email: "restaurant#guy.com", mobile: "8000088888", image: "", password_digest: "$2a$10$H3TlQT1DdGOPQjSR7b1st.SVvAg5XiFidrfqzyqz0RW...", created_at: "2017-02-23 18:19:29", updated_at: "2017-02-23 18:21:43", uid: nil, provider: nil, verified_at: nil, location_id: nil>
Check number of roles:
>> user.roles.length
Role Load (1.0ms) SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1 [["user_id", 337633]]
1 #customer role
Grant the selected user a role on a specific resource:
>> user.grant :restaurant_admin, Restaurant.first
Restaurant Load (1.0ms) SELECT "restaurants".* FROM "restaurants" ORDER BY "restaurants"."id" ASC LIMIT $1 [["LIMIT", 1]]
Role Load (0.0ms) SELECT "roles".* FROM "roles" WHERE "roles"."name" = $1 AND "roles"."resource_type" = $2 AND "roles"."resource_id" = $3 ORDER BY "roles"."id" ASC LIMIT $4 [["name", "restaurant_admin"], ["resource_type", "Restaurant"], ["resource_id", 1], ["LIMIT", 1]]
(1.0ms) BEGIN
(0.0ms) ROLLBACK
HABTM_Roles Load (0.0ms) SELECT "users_roles".* FROM "users_roles" WHERE "users_roles"."user_id" = $1 [["user_id", 337633]]
Role Load (0.0ms) SELECT "roles".* FROM "roles" WHERE "roles"."id" = $1 LIMIT $2 [["id", 4], ["LIMIT", 1]]
#<Role id: nil, name: "restaurant_admin", resource_type: "Restaurant", resource_id: 1, created_at: nil, updated_at: nil>
Role Load (0.0ms) SELECT "roles".* FROM "roles" WHERE "roles"."id" = 4
>> user.save
(0.0ms) BEGIN
true
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."mobile" = $1 AND ("users"."id" != $2) LIMIT $3 [["mobile", "8000088888"], ["id", 337633], ["LIMIT", 1]]
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 AND ("users"."id" != $2) LIMIT $3 [["email", "restaurant#guy.com"], ["id", 337633], ["LIMIT", 1]]
(1.0ms) COMMIT
And save it:
>> user.save
(0.0ms) BEGIN
true
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."mobile" = $1 AND ("users"."id" != $2) LIMIT $3 [["mobile", "8000088888"], ["id", 337633], ["LIMIT", 1]]
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 AND ("users"."id" != $2) LIMIT $3 [["email", "restaurant#guy.com"], ["id", 337633], ["LIMIT", 1]]
(1.0ms) COMMIT
Reload from database:
>> reload!
Reloading...
true
Check if the saved value is present
>> user = User.find(337633)
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 337633], ["LIMIT", 1]]
#<User id: 337633, name: "Restaurant Guy", email: "restaurant#guy.com", mobile: "8000088888", image: "", password_digest: "$2a$10$H3TlQT1DdGOPQjSR7b1st.SVvAg5XiFidrfqzyqz0RW...", created_at: "2017-02-23 18:19:29", updated_at: "2017-02-23 18:21:43", uid: nil, provider: nil, verified_at: nil, location_id: nil>
>> user.roles.length
Role Load (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1 [["user_id", 337633]]
1 #customer role :(
Why wasn't the update persisted?
What am I doing wrong?
UPDATE: Looks like there's no mistake on saving the updated parts but seems to be a bug in rolify gem when operated on Rails 5+
UPDATE 2: The aforementioned bug was resolved I believe, and I finally found what was causing the ROLLBACK -> failing to include resourcify.
Need to include resourcify on the resource that should be assigned to the role and the ROLLBACK was happening as the link was broken.
And I also found that user.save is useless here as the roles get into the db right after you grant them
Based on this SO answer try to call reload on the user object directly:
user.reload
It seems, that the rails console doesn't reload classes once they're referenced.
When you grant the selected user a role on a specific resource, it seems that there's no record add to users_roles.
>> user.grant :restaurant_admin, Restaurant.first
Restaurant Load (1.0ms) SELECT "restaurants".* FROM "restaurants" ORDER BY "restaurants"."id" ASC LIMIT $1 [["LIMIT", 1]]
Role Load (0.0ms) SELECT "roles".* FROM "roles" WHERE "roles"."name" = $1 AND "roles"."resource_type" = $2 AND "roles"."resource_id" = $3 ORDER BY "roles"."id" ASC LIMIT $4 [["name", "restaurant_admin"], ["resource_type", "Restaurant"], ["resource_id", 1], ["LIMIT", 1]]
(1.0ms) BEGIN
(0.0ms) ROLLBACK
HABTM_Roles Load (0.0ms) SELECT "users_roles".* FROM "users_roles" WHERE "users_roles"."user_id" = $1 [["user_id", 337633]]
Role Load (0.0ms) SELECT "roles".* FROM "roles" WHERE "roles"."id" = $1 LIMIT $2 [["id", 4], ["LIMIT", 1]]
#<Role id: nil, name: "restaurant_admin", resource_type: "Restaurant", resource_id: 1, created_at: nil, updated_at: nil>
Role Load (0.0ms) SELECT "roles".* FROM "roles" WHERE "roles"."id" = 4
>> user.save
(0.0ms) BEGIN
true
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."mobile" = $1 AND ("users"."id" != $2) LIMIT $3 [["mobile", "8000088888"], ["id", 337633], ["LIMIT", 1]]
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 AND ("users"."id" != $2) LIMIT $3 [["email", "restaurant#guy.com"], ["id", 337633], ["LIMIT", 1]]
(1.0ms) COMMIT
it was ROLLBACKed.
so i think there's something wrong with the method user#grant

Why isn't acts-as-taggable-on adding tags to posts?

Just set everything in acts-as-taggable-on but now it's not adding tags to posts.
Here's the post model
acts_as_taggable_on :tags
in th user model
acts_as_tagger
in the posts controller
def permit_post
params.require(:post).permit(:image, :title, :long, :anonymous, :facenumber, :hidden, :granted, :tag_list => []);
end
.
puts #tags
#=>ActsAsTaggableOn::Tag Load (0.3ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 26], ["taggable_type", "Post"], ["context", "tags"]]
(0.3ms) SELECT COUNT(*) FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? AND "taggings"."context" = ? [["taggable_id", 26], ["taggable_type", "Post"], ["context", "tags"]]
puts #post.tag_list
#=> 'tag1, tag2,tags'
in the routes
resources :tags, only: [:index, :show]
and when I add a tag I get
ActsAsTaggableOn::Tagging Load (0.1ms) SELECT "taggings".* FROM "taggings" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ? [["taggable_id", 28], ["taggable_type", "Post"]

Can't get the value stored when updating attributes

I am trying to do a marking system for moderators, in which they can select each item as "editor pick".
I've added a :editor_pick column to photos table(boolean)
and added a form in the partial for each item to have a checkbox in it:
<% if controller_name == "photos" %>
<%= simple_form_for [#user, #photo] do |f| %>
<%= f.input :editor_pick, label: "Portada" %>
<%= f.submit "Pick" %>
<% end %>
<% end %>
after that, I required the new param in strong parameters in photos controller
It's redirecting me correctly after the update, but it's not saving the new value.
When I reload the page, the boolean is still false.
My controller actions:
def by_zone
#photo = Photo.find_by(params[:id])
#user = #photo.user
render :index
end
def update
#photo = Photo.friendly.find(params[:id])
if #photo.update_attributes(photo_params)
redirect_to [current_user, #photo], notice: 'El spot se ha actualizado.'
else
render 'edit'
end
end
Edit
def photo_params
params.require(:photo).permit(:editor_pick,:url,:remote_photo_url,:thumbnail_cache ,:order,:string_tags,:tag_list, :sponsored, :photo, :terms, :title,:description,:category_id,:zone_id, :crop_x, :crop_y, :crop_w, :crop_h, sponsors_attributes: [:name, :description, :web, :facebook, :twitter, :sponsored_avatar])
end
Params Edit
Started PATCH "/users/enrique-isasi-12/photos/rustic-plastic-table" for 127.0.0.1 at 2015-01-14 16:43:55 +0100
Processing by PhotosController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"wB2SmOT0zR0dwIIguRhzFdctY51LX333CzGYelxS4Hs=", "photo"=>{"editor_pick"=>"1"}, "commit"=>"Pick", "user_id"=>"enrique-isasi-12", "id"=>"rustic-plastic-table"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 5 ORDER BY "users"."id" ASC LIMIT 1
Notification Load (0.3ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."user_id" = $1 AND "notifications"."viewed_at" IS NULL ORDER BY "notifications"."created_at" DESC LIMIT 30 [["user_id", 5]]
Notification Load (0.2ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."user_id" = $1 AND (viewed_at IS NOT NULL) ORDER BY "notifications"."created_at" DESC LIMIT 30 [["user_id", 5]]
Photo Load (0.4ms) SELECT "photos".* FROM "photos" WHERE "photos"."slug" = 'rustic-plastic-table' ORDER BY "photos"."id" ASC LIMIT 1
(0.4ms) BEGIN
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = $1 ORDER BY "categories"."id" ASC LIMIT 1 [["id", 2]]
Zone Load (0.3ms) SELECT "zones".* FROM "zones" WHERE "zones"."id" = $1 ORDER BY "zones"."id" ASC LIMIT 1 [["id", 6]]
ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL) [["taggable_id", 26], ["taggable_type", "Photo"]]
SQL (0.6ms) UPDATE "photos" SET "editor_pick" = $1, "updated_at" = $2 WHERE "photos"."id" = 26 [["editor_pick", true], ["updated_at", Wed, 14 Jan 2015 15:43:55 UTC +00:00]]
false ActsAsTaggableOn::Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL) [["taggable_id", 26], ["taggable_type", "Photo"]]
(6.1ms) COMMIT
Redirected to http://localhost:3000/users/enrique-isasi-4/photos/rustic-plastic-table
Completed 302 Found in 31ms (ActiveRecord: 9.7ms)

I can't fetch any rows from a Polymorphic association

I've set up 2 polymorphic associations on a table, I have no problem adding to the table but I can't seem to retrieve the added information.
Here's what I'm doing:
Post
belongs_to :posted, polymorphic: true
belongs_to :received, polymorphic: true
User
has_many :posted_posts, class_name: 'Post', as: :posted
has_many :received_posts, class_name: 'Post', as: :received
Group
has_many :posted_posts, class_name: 'Post', as: :posted
has_many :received_posts, class_name: 'Post', as: :received
users_controller.rb
def post
authorize #user
#post = Post.new(post_params)
#post.received = #user
#post.posted = #current_user
if #post.save
respond_to do |format|
format.html {redirect_to root_url}
format.js
end
else
respond_to do |format|
format.html {redirect_to root_url}
format.js
end
end
end
Post seems to be fine, but I should be able to retrieve the information by using
<% #user.received_posts do |post| %>
<%= post.content %>
<% end %>
<% #user.posted_posts do |post| %>
<%= post.content %>
<% end %>
But neither of these work. What am I missing? It's not bringing up an error. In fact, the logs aren't showing anything.. it's like it's being ignored. Do I need a method somewhere that does some lifting? I though the rest is handled by rails..
Any help would be appreciated.
UPDATE - Logs
Started GET "/!/David" for 127.0.0.1 at 2014-08-18 12:02:32 +0100
Processing by UsersController#show as HTML
Parameters: {"username"=>"David"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 ORDER BY "users"."id" ASC LIMIT 1
User Load (0.2ms) SELECT "users".* FROM "users" WHERE (username == 'David') LIMIT 1
(0.2ms) SELECT COUNT(*) FROM "follows" WHERE "follows"."followable_id" = ? AND "follows"."followable_type" = ? AND "follows"."blocked" = 'f' [["followable_id", 3], ["followable_type", "User"]]
(0.2ms) SELECT COUNT(*) FROM "follows" WHERE "follows"."blocked" = 'f' AND "follows"."follower_id" = 2 AND "follows"."follower_type" = 'User' AND "follows"."followable_id" = 3 AND "follows"."followable_type" = 'User'
Rendered users/_links.html.erb (1.2ms)
Rendered users/show.html.erb within layouts/application (7.8ms)
Rendered layouts/_app_sidebar.html.erb (0.8ms)
Mailboxer::Conversation Load (0.6ms) SELECT DISTINCT "mailboxer_conversations".* FROM "mailboxer_conversations" INNER JOIN "mailboxer_notifications" ON "mailboxer_notifications"."conversation_id" = "mailboxer_conversations"."id" AND "mailboxer_notifications"."type" IN ('Mailboxer::Message') INNER JOIN "mailboxer_receipts" ON "mailboxer_receipts"."notification_id" = "mailboxer_notifications"."id" WHERE "mailboxer_notifications"."type" = 'Mailboxer::Message' AND "mailboxer_receipts"."receiver_id" = 2 AND "mailboxer_receipts"."receiver_type" = 'User' ORDER BY mailboxer_conversations.updated_at DESC
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 37]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 44]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 45]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 46]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 43]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 42]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 41]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 40]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 39]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 38]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 36]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.4ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 35]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 34]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 33]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.4ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 32]]
CACHE (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 31]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 30]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 29]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 28]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 27]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 26]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 25]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 24]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 23]]
CACHE (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 22]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 21]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 20]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 19]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 18]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 17]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 16]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 15]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 14]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 13]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 12]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 11]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 10]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 9]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 8]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 7]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 6]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 5]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.3ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 4]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 3]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 2]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Mailboxer::Message Load (0.2ms) SELECT "mailboxer_notifications".* FROM "mailboxer_notifications" WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ? ORDER BY created_at DESC LIMIT 1 [["conversation_id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]]
Rendered mailboxer/conversations/_conversation.html.erb (155.4ms)
Rendered layouts/_app_header.html.erb (159.5ms)
Rendered layouts/_messages.html.erb (0.1ms)
Completed 200 OK in 223ms (Views: 206.2ms | ActiveRecord: 13.5ms)
Turned out that you missed .each:
<% #user.posted_posts.each do |post| %>

Resources