AhmedNadar PRO
Joined 1/22/2017
AhmedNadar PRO said about 2 years ago on Shopping Cart with Turbo :
Wonderful episode as usual David.

Inside `_display` partial I add a `link_to` to show product show view, but it doesn't work. But when I add `turbo_frame: _top` it works which is not an ideal solution.

<%= turbo_frame_tag "products_display" do %>
 <%= content_tag :div, id: dom_id(product) do %>
  <%= link_to product_path(product), data: {turbo_frame:"_top"} do %>
   .......
  <% end %>
 <% end %>
<% end %>

Any idea on how to keep link_to execute by hotwire?
Thanks...

AhmedNadar PRO said almost 2 years ago on Setup and communicate between multiple rails user profile/roles :
As you see above post doesn't show text format as I need. So I will post it below.
Also a suggestion for focus on how to understand relation between objects for MVP product/app and how to handle it when it scales or requirement changes.
-----------

Hi Dave,
This is rather a question than suggestion, and hope i find a help and guidance from you and the community.

A marketplace allows users to buy and sell items. It construct off User model and Item model. Each has many attributes, and their association is:
user.rb
has_many :items, dependent: :destroy, inverse_of: :user

item.rb
belongs_to :user, optional: true, counter_cache: true, inverse_of: :items

Each user show view is alike a profile where it shows all selling items.

Now, I want to introduce 2 type of users. Single seller/buyer (sell and buy few items) and Business (sell bulk/buy small or bulk items).

I created 2 models.

Client
belongs_to :user
has_many :items, dependent: :destroy, inverse_of: :client

Business
belongs_to :user
has_many :items, dependent: :destroy, inverse_of: :business

NOTE: While Business and Client share few attributes, they have many different ones. That's why I created 2 models.

And User
has_one :client, dependent: :destroy
has_one :business, dependent: :destroy

Also Item
belongs_to :client, optional: true, counter_cache: true, inverse_of: :items
belongs_to :business, optional: true, counter_cache: true, inverse_of: :items

While I "feel" it is a good thing to have separate models, I "fell" it's complicated when it comes to item creations and each entity show view.

Required flow

When a user signin, it is redirect to `/roles/new` view and choose to create a Client, a Business or both roles/profiles.

After user have one or both roles, is able to create an item.

Before in `item_controller.rb` I would do 

def new
  current_user.business.items.new
end

Now, I'm not sure. I want to differentiate between which role create an item! 
  def new
    if current_user.client
      @item = current_user.client.items.new
    elsif current_user.business
      @item = current_user.business.items.new
    else
      current_user.items.new
    end
  end

Does it make sense???!!!

Is the user a Client, Business or both. This is needed to show client's items in its' show view, same goes to Business.
While most likely User with either Business or Client role would not create the other role but it could happen. A user have both Business and Client roles.
A user with one or more roles should create an item, this item belongs to the role/profile that created.

I think of it like, an application has Developer and Employer profiles. Both belongs to User model and both could create/has many Projects.

Am I making the process complicated for myself or it is solvable?

AhmedNadar PRO said almost 2 years ago on Deploying to Render :
Fantastic episode. Look forward for more in depth episodes. 
Comparing Render to Hatchbox.io, have anyone tried hatchbox before?
Does Render have any issues similar to heroku as we face now?

AhmedNadar PRO said over 1 year ago :
Hi David,

Thanks for the forums. It is a wonderful idea.
Look forward to more features in the coming future.
Ahmed


AhmedNadar PRO said about 1 year ago on Real-time Comments and Voting :
Hey David,

I want to create Polymorphic commenting and voting systems that they could connect to articles, photos, etc. 
What direction I should follow?