Reputation:
I'm creating an app in rails that has User's and that has Dogwalkers, these users are created on Devise. So, I wan't that a User is able to create a Dog walk for and set, date, time and add the dogs that are going to take for a walk.
I got my Dog's Database on Sqlite:
create_table :dogs do |t|
t.string :name
t.string :photo
t.string :race
t.references :user, foreign_key: true
t.timestamps
end
add_index :dogs, [:user_id, :created_at]
And I got my Walks model:
class CreateWalks < ActiveRecord::Migration[5.2]
def change
create_table :walks do |t|
t.integer :walk_id
t.date :walk_at
t.datetime :walk_start_at
t.datetime :walk_end_at
t.integer :status
t.references :dog, foreign_key: true
t.references :user, foreign_key: true
t.references :dogwalker, foreign_key: true
t.float :dogprice
t.integer :doglimit
t.timestamps
end
add_index :walks, [:user_id, :created_at]
end
end
So how can I make that the user is able to create a Walk, and let the Dog walker able to see it on it's own dashboard (which I already created). The Dog Walker will accept it and it will send a notification to the user that it has been accept it. Once the user has received there dog's the walk has finish and create a history of the walk.
What I been doing:
Hope this possible! Thanks for you help!!!
Upvotes: 0
Views: 73
Reputation: 1729
I think what you want to do is create a form for a new Walk. The user(dog owner) will fin the required fields, like date, walk_start_at and walk_end_at. Maybe some more, but that's up to you.
On the users dashboard(the dogwalker) you can list all walks that available by:
@walks = Walk.where(dogwalker: nil)
This will give you all the walks that don't have a walker yet. For each of these walks you also add a form for walk that only needs a submit button. When the dogwalker hits the button it goes to the update action from the Walk. There you receive the params and you can set the dogwalker.
Now on the dogowner can see that the walk is accepted.
Upvotes: 1