-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marketplace: Products Controller persists Products! #856
Marketplace: Products Controller persists Products! #856
Conversation
This starts to shift our Furniture and Item system away from an inheritance oriented rails-adjacent structure to a more Rails-forward structure. Furniture now places it's routes against the *room*, which allows it to support either Singleton-type Resource routes, or more traditional Resources routes. Further, it brings the `Placeable` interface a bit closer to ActiveRecord; which should reduce pain-points as we unwind the current overly-restrictive and complex Furniture/Item design.
ffe5713
to
714bd48
Compare
expect(created_product.price_currency).to eql(Money.default_currency.to_s) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(╯°□°)╯︵ ┻━┻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NEEDS MORE TABLE FLIP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the happiest I've ever been!!!!1!!
Seriously, good work. I like it. 😻
end | ||
|
||
factory :marketplace_product, class: 'Marketplace::Product' do | ||
name { Faker::TvShows::DrWho.specie } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Faker choice. 👽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted one that was more nerdy equipment but I can't always get what I want!
end | ||
end | ||
|
||
# Appends each Furnitures CRUD actions within the {Room} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: On the line below, is the routing_context
actually just the router
? That seems to be at least the variable name you are using in e.g. Marketplace.append_routes
. router
seems clearer to me than routing_context
-- I don't know what the latter is.
@@ -14,7 +14,15 @@ module Furniture | |||
spotlight: Spotlight, | |||
}.freeze | |||
|
|||
# Appends each {Furniture}'s CRUD actions | |||
# Appends each {Furniture}'s CRUD actions under a FurniturePlacement | |||
# @deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
app/furniture/marketplace.rb
Outdated
Marketplace::Product.where(space: space) | ||
end | ||
|
||
def to_partial_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment that this implements https://apidock.com/rails/v6.1.3.1/ActiveModel/Conversion/to_partial_path , for clarity (I had to look up what was this doing, I wasn't familiar with this method, as I've never had the need to implement this myself).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it!
locals: { furniture: furniture_placement.furniture, space: furniture_placement.space, room: furniture_placement.room, | ||
person: current_person } %> | ||
<%- else %> | ||
<%= render furniture_placement.furniture %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much cleaner!
Rails assumes that your parameter names will match the namespace of the model. For example, a `Marketplace::Product#name` Rails will make HTTP Params of `marketplace_product[name]`, I had previously assumed it would name them `product[name]` because I thought it would discard the stuff before the `::`. Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>
@anaulin had suggested that `routing_context` was confusing; and I agree. It's just the router! So let's name it that way! Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>
Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com>
* Add scaffolding for new Marketplace furniture. Co-authored-by: Sadie Jay <19538219+sadiejay@users.noreply.github.com> Co-authored-by: Zee <zspencer@users.noreply.github.com> * Replace money gem with money-rails. Co-authored-by: Sadie <19538219+sadiejay@users.noreply.github.com> Co-authored-by: Zee <zspencer@users.noreply.github.com> * Add Marketplace::Products model, table (not Items!), form and controller. Co-authored-by: Sadie <19538219+sadiejay@users.noreply.github.com> Co-authored-by: Zee <zspencer@users.noreply.github.com> * Marketplace: Products Controller persists Products! (#856) This starts to shift our Furniture and Item system away from an inheritance oriented rails-adjacent structure to a more Rails-forward structure. Furniture now places it's routes against the *room*, which allows it to support either Singleton-type Resource routes, or more traditional Resources routes. Further, it brings the `Placeable` interface a bit closer to ActiveRecord; which should reduce pain-points as we unwind the current overly-restrictive and complex Furniture/Item design. * Marketplace: Products are shown! * Use correct parameter name in request spec Rails assumes that your parameter names will match the namespace of the model. For example, a `Marketplace::Product#name` Rails will make HTTP Params of `marketplace_product[name]`, I had previously assumed it would name them `product[name]` because I thought it would discard the stuff before the `::`. Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> * Rename from `routing_context` to `router` @anaulin had suggested that `routing_context` was confusing; and I agree. It's just the router! So let's name it that way! Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> * All `Placeable` now implement `to_partial_path` Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> Co-authored-by: Zee Spencer <zspencer@users.noreply.github.com> Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> * Fix method lookup in class ancestry Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> * Marketplace: Present Products in a much cleaner way Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> * Adds Button to add Products to Marketplace Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> * Marketplace: Add Products to Product Table via TurboStreams This makes the user experience for adding a product even tighter; by hiding the Product form until the Distributor is adding a new product. Once they do, we replace the entire marketplace with the New Product form; and upon successful create, we replace the entire marketplace with the full Marketplace view! Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> * Fixed test by redirecting to room rather than marketplace Still need to figure out how to redirect to furniture Co-authored-by: Kelly <KellyAH@users.noreply.github.com> Co-authored-by: Zee <zspencer@users.noreply.github.com> Co-authored-by: Ana <anaulin@users.noreply.github.com> * Marketplace: Validate product names Validate that `Marketplace::Product` belongs to a space Co-authored-by: Kelly <KellyAH@users.noreply.github.com> Co-authored-by: Zee <zspencer@users.noreply.github.com> Co-authored-by: Ana <anaulin@users.noreply.github.com> Co-authored-by: Sadie Jay <19538219+sadiejay@users.noreply.github.com> Co-authored-by: Zee <zspencer@users.noreply.github.com> Co-authored-by: Zee <50284+zspencer@users.noreply.github.com> Co-authored-by: Neer Thapa <nirmalathapa@users.noreply.github.com> Co-authored-by: Kelly <KellyAH@users.noreply.github.com>
This starts to shift our Furniture and Item system away from an inheritance oriented rails-adjacent structure to a more Rails-forward structure.
Furniture now places it's routes against the room, which allows it to support either Singleton-type Resource routes, or more traditional Resources routes.
Further, it brings the
Placeable
interface a bit closer to ActiveRecord; which should reduce pain-points as we unwind the current overly-restrictive and complex Furniture/Item design.