Rails 4 + Simpleform + datetimepicker-rails How do I add a default time of 6:45pm | Fixed issues |
- Rails 4 + Simpleform + datetimepicker-rails How do I add a default time of 6:45pm
- How to delete a collection matching a condition
- React on Rails - ! [remote rejected] master -> master (pre-receive hook declined)
- Rescuable after_commit callbacks (Rails 3)
- best practice : should i create a new controller or not ? in order to respect a good architecture
- Ruby on Rails function for model attribute
- How do you get a list from complex active record has_many involved from a subset of downstream objects
- How does one integrate Duo Mobile with Devise and Rails?
- Devise 401 Unauthorized
- undefined method `permit' for "<p>tinymce</p>":String
- Add autocomplete feature to rails app with selectize.js
- Rails: Serialization of custom class for flash messages
- Rails + Devise ActionController::InvalidAuthenticityToken
- Rails: load different modules for each environemnt
- Sprockets::FileNotFound with jquery-ui-bootstrap
- Sunspot Solr fulltext search
- Issue regarding cursor styling for a disabled button by javascript
- Mouse over to display more information using jquery with rails model
- Ruby Object mutations within sidekiq workers
- truncate and restart identity of a set of tables
- how to display one controller show action in another controller action in rails
- Rails: Change Status Onclick
- PDFKit Unknown long argument --root-url
- RSpec before in a helper
- Have username instead of id then nested route /users/:id/nest_routes to /username/nested_routes
- ruby on rails error config_check.rb:87:in `initialize':
- Testing a belongs_to relationship in Rails with rspec
- Rails bootstrap color depending on value
- Double has_many attributes
- Extract Data from Excel Spreadsheet into Database in Ruby
Rails 4 + Simpleform + datetimepicker-rails How do I add a default time of 6:45pm Posted: 24 Jan 2017 08:22 AM PST Want to have a default time of 645pm in a form. I am using Rails 4 , Simple form & datepicker bootstrap gem. = f.input :started_at, as: :string, class: 'form-control', input_html: { value: l(@happening.started_at, format: :date_time_picker), class: 'date_time_picker' }, label: "Start at" I have tried a number of things including using default: '645' after the date_time_picker and reading the Simpleform documentation |
How to delete a collection matching a condition Posted: 24 Jan 2017 08:19 AM PST I would like to delete all posts associated to every user of my application matching a determined condition. In particular I would like to delete all posts older than 30 days only if a user has more than 20 posts. At first I wrote the following code: However, looking at the API documentation, method Therefore, considering that method or am I expected to use something different? |
React on Rails - ! [remote rejected] master -> master (pre-receive hook declined) Posted: 24 Jan 2017 08:18 AM PST I'm working in rails 4.2.5, recently I have added Any help is much appreciated. |
Rescuable after_commit callbacks (Rails 3) Posted: 24 Jan 2017 08:06 AM PST I have a model with several I want to ensure that all callbacks are ran (even if one fails), without explicitly wrapping each of them with Is there a way to so? I've looked into rescuable option of In this case, callback |
best practice : should i create a new controller or not ? in order to respect a good architecture Posted: 24 Jan 2017 08:20 AM PST I'm working on an application where both notifications and history are needed, and what makes it quite difficult is the fact that there is the notion of 'context'. For example when the user is in a certain view, he must see only the notifications and the histories related to that context. There is a controller for each, but when I want to update the notifications in the client side ( live update using the Pusher ), from the server side I need to know the context where the user is. The solution put in place is to send an ajax request from the client side specifying the context he is in, with the route of course. Now the question is, in order to respect a good architecture, since the ajax request sends the context which is used for both notification and history, should I create a controller to deal with that ( and then that controller will contact both controllers ) or should I use one of them?. Thanks |
Ruby on Rails function for model attribute Posted: 24 Jan 2017 08:09 AM PST I have one active record model called
How do I create a function for priority so I can call it something like this
I don't want to override the attribute method to print out the string because I need to access the actual value. |
Posted: 24 Jan 2017 08:17 AM PST I'm having a hard time getting a list of the leagues involved from a subset of games. Data Examples: Given a subset/collection of Game objects[G1,G4], is there a way to return the Leagues associated? (Return AFC & NFC) Find all Games that have NFC teams [G1,G3,G4] The challenge Im having with is the home_team / away_team seperation thanks |
How does one integrate Duo Mobile with Devise and Rails? Posted: 24 Jan 2017 07:55 AM PST The documentation for Duo's supported Ruby library is sparse. This question understandably mentions overriding Devise's session controller, but how? There does not seem to be a source for a clear explanation of how to integrate Duo with Devise. There is this gem, but it doesn't seem to be very active and I couldn't get it working. How do I do this? |
Posted: 24 Jan 2017 07:43 AM PST I'm using Ruby 4.2.3 and Devise 4.2.0 and I'm trying to sign in using POST method ($resource AngularJS) but 'I'm getting 401 Enauthorized error ('You need to sign in or sign up before continuing') I'm following this Documentation which is working fine if I try outside my app. For instance using 'Postman'. Alright, some code: My angular controller to send the log in data to server: my session devise controller (as exactly as the tutorial) my postman example that shows that is working: What am i missing? I try to look out all around but I couldn't find any updated info. Any guide you could recommend? Thanks! |
undefined method `permit' for "<p>tinymce</p>":String Posted: 24 Jan 2017 07:56 AM PST Im trying to implement tinyme gem and I get this error: This is the controller: The View: How should I fix this issue ? |
Add autocomplete feature to rails app with selectize.js Posted: 24 Jan 2017 07:34 AM PST It's been two days that I'm fighting on a "simple" task. Adding an autocomplete field in a form on my rails application. I'm running ruby 2.3.3 and rails 5.0.1. So far I've tried a bunch of different options such as: - Elasticsearch - Rails-jquery-autocomplete Now I'm giving a go to selectize.js. I added the gem to my gemfile: And I have included it in my application.js I have created an action in my controller that returns the data from a table called Interests in a json format: And in my script, I'm using the following (taken from here using the rottenTomato example): Although I do see the AJAX call made and the JSON returned, not much is going on on the actual page. Any suggestion on the matter is the very welcome (or any other sort of help to get an autocomplete system up and running for that matter :) ). Cheers! Andrea Update: Here is the console output after changing the ajax call (see above) |
Rails: Serialization of custom class for flash messages Posted: 24 Jan 2017 07:06 AM PST I can't seem to figure out how flash messages in RoR insist on being serialized for the next page view. When setting a simple type to e.g. flash[:notice], all is well to get it across to the next page view. When I however try and set the value of flash[:notice] to a custom class, it serializes only the properties: ... equates to ... ... which has no knowledge of the class it serialized. One solution I found was to use .to_yaml before doing a redirect, and then use YAML.load at the later step, but I don't find that viable. So my question is, how would I be able to make sure that it automatically serialize this object, to properly be deserialized at a later stage? Rails: 4.2.5.1, Ruby: 2.2.4p230 Thanks |
Rails + Devise ActionController::InvalidAuthenticityToken Posted: 24 Jan 2017 07:03 AM PST Cheers! I use Devise gem for authenticating users and locally (development env) I always get this ActionController::InvalidAuthenticityToken exception on All right, no more authenticity_token exceptions, I don't mind if it happens only in dev env. But! There is another problem - router.rb What could be the origin of this issue?
|
Rails: load different modules for each environemnt Posted: 24 Jan 2017 06:52 AM PST I have rails application with two environments. Each environment has its own schema. How can configure rails to load specific modules for each environment? e.g modules |
Sprockets::FileNotFound with jquery-ui-bootstrap Posted: 24 Jan 2017 07:09 AM PST Strange issue. Following the gem's docs I seem to be running into the error, Sprockets::FileNotFound in PostIndex: Here is how I have my files setup: Gemfile application.css application.js I'm using the latest versions of all of these gems. |
Posted: 24 Jan 2017 06:17 AM PST I'm having some trouble getting the right results in when searching my Initially, I was doing a fuzzy search using I need to be able to search the In my And my initial search string was: This worked relatively fine, however any result that might have been 'close' to what the person was looking for was being returned. So, if the person searches for So, I've decided I need to do away with fuzzy search and get more specific. If someone searches I need only those specific results to return, based on what's in the I was thinking about doing an exact phrase search, but I can't interpolate the variables that are being passed when doing this because of the double-quoting requirement. It just returns the literal string: Is there a way around this so I can minimize incorrect results from showing? Update I found a way around the double-quoting requirement by wrapping my dynamic content in Is there a happy medium? |
Issue regarding cursor styling for a disabled button by javascript Posted: 24 Jan 2017 06:45 AM PST In my ruby on rails application I am using some javascript on one of my view page to make a submit button with id "submitorder" disabled. And I have done this successfully using the following line of code. It is working fine. But now I want to make the cursor as 'not-allowed' also when hovering on that submit button. That's why I have used the following lines of code to make the submit button disabled and as well as to make the cursor as 'not-allowed' But unfortunately the button becomes disabled only. There is no change in the cursor styling. Please tell me why this is happening and give me clues to figure out this. Thanks in advance!! |
Mouse over to display more information using jquery with rails model Posted: 24 Jan 2017 05:37 AM PST I have 5 rows of 10 buttons arranged in a table. This represents a vending machine where there are 5 rows of 10 slots each. Each button displays basic information such as quantity of the items left in that slot. This is already done. I want to allow mouse over the buttons to pop up a bigger window to show more information about each of the slot.These information must be retrieved from the vending machine model. It is not like popover where I just enter some static text. Here I have to query the db to display actual data. html.erb any suggestions on how I could achieve that? thank you. |
Ruby Object mutations within sidekiq workers Posted: 24 Jan 2017 07:41 AM PST I have a wrapper that sends user updates to an external service, on a regular basis, running inside a Sidekiq worker. Each User has its own Sidekiq Job. Sidekiq is setup to use 20 threads. It's a Rails 5.0.1 app, MRI Ruby 2.3.0. Webserver is Passenger 5 Community. If I over simplify, the code looks like this: Now, the BIG problem that I only have on production and I finally catched up by looking at the logs can be summarized like this : 2 Questions:
Ultimately, is there any way to really battle test this kind of code so I can be sure not to mix users data? |
truncate and restart identity of a set of tables Posted: 24 Jan 2017 05:44 AM PST My application uses In the Postgresql documentation I found that TRUNCATE with RESTART IDENTITY would do the job as follows: According to How to restart id counting on a table in PostgreSQL after deleting some previous data? at Stackoverflow, I can use the following command: So putting together the two documentations, would it be correct to use the following command: considering that in the API dock documentation the |
how to display one controller show action in another controller action in rails Posted: 24 Jan 2017 05:17 AM PST I am using two controller incident and incident_list, i am displaying all incidents in incident_list/index page when click on show button in each incident i want to display that incident details IncidentListController IncidentController incidnet_lists/index.html.erb incidents/show.html.erb when click on show button in the incident_list page incident show page should be display |
Posted: 24 Jan 2017 04:56 AM PST |
PDFKit Unknown long argument --root-url Posted: 24 Jan 2017 05:55 AM PST I'am trying to use the My code: returns versions: wkhtmltopdf 0.12.4 pdfkit 0.8.2 tested also with wkhtmltopdf 0.12.3 pdfkit 0.8.0 |
Posted: 24 Jan 2017 04:38 AM PST Is it possible to do something like this? Then in my tests I could do something like: EDIT: This produces the following error: Essentially I have a case where many tests do different things, but a common model across off of them reacts on an after_commit which ends up always calling a method which talks to an API. I dont want to GLOBALLY allow |
Have username instead of id then nested route /users/:id/nest_routes to /username/nested_routes Posted: 24 Jan 2017 03:42 AM PST Hello i have heaps of routes such as the following They all produce the following route
For instance an edit shipping method view produces the following
How do i make all these routes produce this:
For example the edit shipping method view above should produce the following:
|
ruby on rails error config_check.rb:87:in `initialize': Posted: 24 Jan 2017 03:43 AM PST I have just installed ruby on rails and can not figure out whats wrong with it whenever I run it gives the following error: |
Testing a belongs_to relationship in Rails with rspec Posted: 24 Jan 2017 02:51 AM PST I have a model called Page that has many Paragraphs. This all works but I thought it was about time I had some tests. For reasons, I need a count of all the paragraphs a page has, +1 so I know how to number the next paragraph. I do this with a count_paragraphs method in my model: So far so simple. This works fine in my controller, where I use it to create the next paragraph. As mentioned this all works. But in testing, this does not work: The first test passes, the second does not. It always returns 1. When I binding.pry the test, each new paragraph shows up if I do Does anyone have any idea what I'm doing wrong here? |
Rails bootstrap color depending on value Posted: 24 Jan 2017 05:03 AM PST
|
Posted: 24 Jan 2017 07:49 AM PST I'm beginner in rails and having trouble finding a proper way out with my problem. I have three models : Conversation, participant, messages which have the following attributes : Conversation : Participant : Message : My trouble is that I'm trying to make a single form to create a conversation with a first message in it. The form looks like this : I've tried many ways to make this form simple but I've encountered some problems which I don't know how to fix using rails properly. I've tried using So basically I want my first form, once validated, to create a conversation, link the current user to that conversation and link the message to that first user, but I assume there are ways to do it with the framework and I would not like to do it manually. What is the proper way to follow to achieve that? Am I even on the good track or shoould I change something or add something? Edit : to make it more understandable, a participant got a user_id and a conversation_id, which means this is a relation table. I can't adapt the attributes of my models to make it easier since I must keep it in that way for security reasons. |
Extract Data from Excel Spreadsheet into Database in Ruby Posted: 24 Jan 2017 02:47 AM PST I'm looking to extract quite a lot of data from spreadsheets for a Rails application, but I'm doing the extraction through the Rails Console. I have a table called I thought that using the find_or_create_by method would be the best move for this. The spreadsheet has Using the Roo gem, I've got this so far: This is giving the error I'm using Ruby 2.2.3 and Rails 5.0.1 Edit:
|
You are subscribed to email updates from Newest questions tagged ruby-on-rails - Stack Overflow. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
No comments:
Post a Comment