ruby-on-rails-5

resque-web with rails api only mode

房东的猫 提交于 2019-12-24 08:27:04
问题 1. What is the best way I can use resque-web with rails API-only mode? My application uses resque with four separate job servers fur running the queues. I have mounted resque-web and I run it on local machine. it works fine only to show me the information about workers and queues. However, if I try to 'retry failed' jobs or 'delete a queue', it gives me routing error. 2. Is there any readymade way to expose all the routes used by resque-web as a json API? So that I can design my own JS front

Rails 5 problems with multiple manifest files

丶灬走出姿态 提交于 2019-12-24 08:26:25
问题 thanks for your help. My Problem In my Rails 5 application I have 2 layouts, for this reason I need to set up multiple manifest files. What I have done I did the following: The two layouts have a user.html.erb and a main.html.erb html file, there I linked with the correct tags my application.js in user.html.erb and my main.js for main.html.erb . The file loads, if I follow localhost:3000/assets/application.js the full content of the js files included in the manifest is displayed, while at

Showing error messages for nested resources in Rails

与世无争的帅哥 提交于 2019-12-24 07:45:31
问题 I am creating my first app, simple blog, and I don't know how to show error messages for nested resource(comments) that doesn't pass validation. this is create action for comments: def create @post = Post.find(params[:post_id]) @comment = @post.comments.create(comment_params) redirect_to post_path(@post) end this is comment form: <%= form_for([@post, @post.comments.build]) do |f| %> <p> <%= f.label :commenter %><br /> <%= f.text_field :commenter %> </p> <p> <%= f.label :text %><br /> <%= f

Curl command to DELETE from rails API based on where predicate?

独自空忆成欢 提交于 2019-12-24 07:35:28
问题 I can see from here how to delete a table record by id i.e. this deletes the user record with id = 1 curl -X DELETE "http://localhost:3000/users/1" But what if I wanted to delete records based on something else, e.g. all users with name: "John" , how would that be done via a curl command? Update: I thought curl -X DELETE -d "name=John" "http://localhost:3000/users" may work, but it doesn't 回答1: In that scenario, the API would change a bit. The route for the default DELETE API on Rails

By filling in the code marked FILL_IN in Listing 3.42, write a test for the root route

做~自己de王妃 提交于 2019-12-24 06:10:12
问题 Adding the root route in Listing 3.41 leads to the creation of a Rails helper called root_url (in analogy with helpers like static_pages_home_url). By filling in the code marked FILL_IN in Listing 3.42, write a test for the root route. Listing 3.41: Setting the root route to the Home page. config/routes.rb Rails.application.routes.draw do root 'static_pages#home' end Listing 3.42: A test for the root route. green test/controllers/static_pages_controller_test.rb require 'test_helper' class

Bad URI on rails javascript_include_tag and stylesheet_link_tag

此生再无相见时 提交于 2019-12-24 04:29:44
问题 So I took a few months out from this project, went to it today and tried to host it, and without touching anything I am getting a bad URI error on two links to my javascript and css. <%= javascript_include_tag "application", "data-turbolinks-track": "reload" %> <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track": "reload" %> Those are the two pieces of code causing the errors. Does anyone know what the problem could be, I have tried all combinations of double/single

Rails route appears in routes but throws a 404

社会主义新天地 提交于 2019-12-24 02:16:26
问题 I'm trying to add a simple route to an existing controller/action but strangely I'm getting a 404 error even though the route appears to exist. Here's the relevant section of my routes.rb : # Wines scope 'wine' do get '/', to: 'wines#index', as: 'wine_index' get '/:collection', to: 'wines#collection_detail', as: 'collection_detail' get '/:collection/:slug', to: 'wines#wine_detail', as: 'wine_detail' get '/:style', to: 'wines#style_detail', as: 'style_detail' end It seems correct because here

Show last message in a message array

╄→гoц情女王★ 提交于 2019-12-24 01:44:57
问题 Regarding my last attempted answer, I could achieve what I wanted. Once the app is working I noticed something is different: only the person that created the message and sends a message was only showing. If I reply, I do not see the reply and I know the problem. My Message model has tables: [:id, :user_id, :to, :body, ...] :user_id would be similar to from as that is used to determine who created the message. User 1 would be Client and User 2 is Student. Student sends a message to Client.

Can not find jsonapi parser 0.1.1

∥☆過路亽.° 提交于 2019-12-24 01:29:34
问题 When I run rails server, 'Could not find jsonapi-parser-0.1.1.beta2' error shows up. ~/ruby_on_rails/test/sampleapp$ rails s Could not find jsonapi-parser-0.1.1.beta2 in any of the sources Run `bundle install` to install missing gems. ~/ruby_on_rails/test/sampleapp$ bundle install Fetching gem metadata from https://rubygems.org/......... Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Could not find jsonapi-0.1.1.beta4 in any of

Rails counter cache with condition

大憨熊 提交于 2019-12-24 00:54:44
问题 I have a rails hotel application which has rooms inside it. Rooms can have n number of tickets associated to them. I have create a counter cache with counter culture gem which updates the room table with number of tickets assigned to it, the problem is i only want count of tickets which are open or in progress state. I have this code it works fine normally but does not work with the condition can anyone guide me by letting me know how can i work it with conditions? Any help is appreciated