market_place_api
market_place_api copied to clipboard
Sabisu Rails Browser Interface - how can be used to create, update, delete user
I am at the end of chapter 6. Everything works well, all tests are green. Here is the question. How I can use the Sabisu browser interface http://localhost:3000/sabisu_rails/explorer to delete, or update, or create an user? Im selecting DELETE instead of GET, I am entering the user id 2 and press Enter and no user is deleted. Also I am getting the message: { "errors": "Not authenticated" }
That means you have to add the Authorization
header to the request in order to remove that user.
I don't know how to do this addition.
On Wed, Apr 29, 2015 at 1:07 PM, Abraham [email protected] wrote:
That means you have to add the Authorization header to the request in order to remove that user.
— Reply to this email directly or view it on GitHub https://github.com/kurenn/market_place_api/issues/20#issuecomment-97506165 .
Levi
On the sabisu dashboard, you have a Headers
button, you can click on it and some fields will appear, you can add the Authorization header in there, something like:
Many thanks, it worked, I was able to delete one user and the associated product. But how to create a new record or to update and existent one? I did couple unsuccessful attempts.
On Wed, Apr 29, 2015 at 2:42 PM, Abraham [email protected] wrote:
On the sabisu dashboard, you have a Headers button, you can click on it and some fields will appear, you can add the Authorization header in there, something like:
[image: screen shot 2015-04-29 at 1 41 13 pm] https://cloud.githubusercontent.com/assets/236312/7398567/8afa5f62-ee75-11e4-8b34-50d1e726b664.png
— Reply to this email directly or view it on GitHub https://github.com/kurenn/market_place_api/issues/20#issuecomment-97536224 .
Levi
Just change the HTTP method from the select to a POST/PUT/PATCH and a form should appear, something like the image below:
You will probably need to send a header, I'm not quite sure, but you already know how to do that.
I did exactly so. I changed from GET to PATCH for update lets say and I entered values in the formed shown. But after I click the Send button nothing was changed. I also used Authorization. I did in similar way for creating a new product and nothing was created.
On Thu, Apr 30, 2015 at 1:02 PM, Abraham [email protected] wrote:
Just change the HTTP method from the select to a POST/PUT/PATCH and a form should appear, something like the image below:
[image: screen shot 2015-04-30 at 12 01 07 pm] https://cloud.githubusercontent.com/assets/236312/7418079/ae400434-ef30-11e4-8d5c-030a08c29e92.png
You will probably need to send a header, I'm not quite sure, but you already know how to do that.
— Reply to this email directly or view it on GitHub https://github.com/kurenn/market_place_api/issues/20#issuecomment-97882242 .
Levi
This is what I am using for updated product 2 belonging to user 2.
You don't need to pass the user id as the product is created under the current_user
scope.
Now to customize this in sabisu, open the sabisu_rails.rb
file and update the resources array to:
config.resources = [:users, :products => [:title, :price, :published]]
Make sure the request is sent correctly, and that the header is up to date with the token.
Check out the development.log
file, before performing the request I recommend you to erase that file content so it is easier for you to see the request.
OK, I did the following changes, including that one you suggested and now everything works well.
The changes in the routes.rb file are (the log file shown some paths not found):
resources :users, :only => [:show, :create, :update, :destroy, :index] do
resources :products, :only => [:create, :update, :destroy]
end
resources :products, :only => [:show, :index, :update, :create, :destroy]
The changes in the initializers/sabisu_rails.rb file are:
config.resources = [ :users => [:email, :password, :password_confirmation], :products => [:title, :price, :published] ]