Use data from database in Chart.js/Rails | Fixed issues |
- Use data from database in Chart.js/Rails
- rails creating relationships between 2 existing models
- Should I default jsonb to '{}' or {} in migration
- Activerecord query with group on multiple columns returning a hash with array as a key
- Ruby form parameters are null
- Rails token authentication with API. Where does the token go?
- ruby on rails virus using server for ddos
- How to use the selected date on the previous page?
- I am facing the routing error in rails as uninitialized constant UserController
- How to manage statuses associations in rails
- Rails - Do not send message if user not approved
- Rails Can't verify CSRF token authenticity ajax with X-CSRF-TOKEN header
- How to make notice when image gets uploaded with Paperclip
- Converting array/hash to string and converting that string back to array/hash in ruby
- Rails DataTables warning Ajax error please see http://datatables.net/tn/7
- Rails, "undefined method `variant' for nil:NilClass" on render json
- How can show current_user's friends' posts and what's popular in one record?
- undefined method contact_path in rails form
- Ruby on Rails - Adding sort order to album images
- Ruby on rails web application
- Boolean value in RAIL API
- binding_of_caller gem error in Rails 3.2.13
- Rails_Admin select tag for n-n association
- Ruby cannot JSON.parse(file.to_json)
- Rails: How to start thin server in ssl
- Rails error while migrating to heroku
- Redirect_to not working as expected
- Paperclip separate styles
- Rails: Provide default value for the disabled select helper
- Rails, a way to render everything my app has in one json?
Use data from database in Chart.js/Rails Posted: 03 Jun 2016 07:10 AM PDT I want to show a line chart on my "Weights" index page with Chart.js in my Rails app (a weight loss app). I have a table that holds a user's weight (as "kilograms") for each day (as "day"). I am able to show a line chart, however, but only with static data - not with the data from my Weights table. What I want to do now is to have "day" on the x-axis and "kilograms" on the y-axis. How can I achieve this? And as I just started coding few months ago: how should the code look like? Thx a lot. This is the code from my weights index.html.erb: |
rails creating relationships between 2 existing models Posted: 03 Jun 2016 07:18 AM PDT I have 2 models: creating these models created 2 tables in the database: now I want to add a relationship:
I ran the following command: which created the following migration: now I'm a little confused: why does the migration say also, after (or before) creating this migration, I have to add as a side question, is there a way to add |
Should I default jsonb to '{}' or {} in migration Posted: 03 Jun 2016 07:18 AM PDT Of the scarce instructions I've read about adding Postgres's data type But is there any reason against defaulting to Hash intead of String, i.e. When defining it to String type, the class of that column: When defining it to Hash type, the class of that column: |
Activerecord query with group on multiple columns returning a hash with array as a key Posted: 03 Jun 2016 07:05 AM PDT I wrote an
This returns:
Now my question is, how do I access the values in this hash? Doing something like However I want to know if there is a more idiomatic way to access the values, something similar to |
Posted: 03 Jun 2016 06:44 AM PDT I'm completely newbie to ruby, and my boss put me to develop a new module in a ruby system. I just need to create a new page in the dashboard to create some "Service Plans", is just a name, discount percentage and a list of services. I looked how they created other pages and tried to copy them. My page is almost EXACTLY the New Professionals page. I created a form.haml, a model, a controller and a Plan Form class (they use it to validate the form.) But when I try to use some parameters in the Plan Form class, they are just nil! Here is my code:
Images legends: 1 - My Plan Class 2 - My Plan Controller 3 - My partial _form haml 4 - My Plan Form Class where the posted date should be validated and saved. 5 - My console with the Result and messages 6 - The rest of result. Look at parameters line: the services id's are there! > how can I access them? My questions are: First: My classes are exactly the same, why doesn't it work? Second: How can I access the Parameters inside the Plan Form class? Third: Are there any other better way to do that? Thank you very much guys! Sorry for the mistakes/wrong format, is my first question here. |
Rails token authentication with API. Where does the token go? Posted: 03 Jun 2016 06:20 AM PDT First of all, I am fairly new to Rails and this is the first time I'm trying to use a token based authentication process! So, in my sessions_controller (client app) I have this snippet to fetch the user token from my Rails API: And on my application_controller (api app) I have this: So, my problem is: when we reach the point where all subsequent requests need to pass through "authenticate_user_from_token", there is no token to authenticate from. Should I store the token in the client session? Do I have to specify the token in every request I make? Thanks in advance! |
ruby on rails virus using server for ddos Posted: 03 Jun 2016 05:57 AM PDT How to clean ruby on rails app if I've been infected with some virus that uses my DigitalOcean server to send outgoing traffic? Probably for ddos attacks. I just made new droplet with all security updates, but when I run bunndle install it started to spit large traffic. |
How to use the selected date on the previous page? Posted: 03 Jun 2016 06:46 AM PDT How to use the selected date on the previous page? We get the value date: Controller: view selectday receives parameters: Here it is necessary to print the selected date. Call object in selectday view, but no output it: |
I am facing the routing error in rails as uninitialized constant UserController Posted: 03 Jun 2016 05:52 AM PDT I am going create a rail application which takes input from an csv file and show it on the webpage. After doing all the needful stuffs I am facing this: Routing Error My app\controllers\users_controller.rb file is:- My app\model\user.rb file is:- class User < ActiveRecord::Base require 'csv' My app/views/users/index.html.erb file is:- My config\routes.rb file is:- I have not posted any #marked commented line from routes.rb file here. The snapshot of the output screen is here:- when clicking on the import csv button the following error is shown: enter image description here enter image description here |
How to manage statuses associations in rails Posted: 03 Jun 2016 05:54 AM PDT Say for example I have an Order and Status. Status:
Order:
How to manage the association in Ruby on Rails? Would the following code is the best choice? |
Rails - Do not send message if user not approved Posted: 03 Jun 2016 05:26 AM PDT I have a rails app and user model. User can sign up the form but the admin should approved his/her profile first. So I have status :boolean default to false column in user model. You can search user on search field. I do not show those users if status column is false. BUT Lets say user with an id 5 is not approved meaning status column is false. if user types .../en/users/5 it goes to that url and can send messages. How should I do that so they cant send email. I should have something like; and where should I put this?. To user controller#show action as before filter? |
Rails Can't verify CSRF token authenticity ajax with X-CSRF-TOKEN header Posted: 03 Jun 2016 04:57 AM PDT I try to register a service worker endpoint in my database but when I send my post data with fetch the app raise an error. I want to keep the csrf verification. Do you see something wrong ? thanks |
How to make notice when image gets uploaded with Paperclip Posted: 03 Jun 2016 05:09 AM PDT Is there any way to include a notice on a page like "Successfully Uploaded" when image gets uploaded with Paperclip? Avatar upload is part of my simple form here is a current code: my application_helper.rb and in user.rb: |
Converting array/hash to string and converting that string back to array/hash in ruby Posted: 03 Jun 2016 04:28 AM PDT I had this array lets say, so now Now the array is not an array its a string which is like this: If I do I want to convert this back to array so that I can use Full Code: The thing is that I have already saved stuff like that in the database, so now I need to use that stuff back, so the only way is to parse the saved string (which was actually an array). |
Rails DataTables warning Ajax error please see http://datatables.net/tn/7 Posted: 03 Jun 2016 04:14 AM PDT Im using ruby on rails with datatables, When i type in the search box, it pops up this error Here is my code: index.html.slim https://gist.github.com/anonymous/8953b680e4dfe6f2e6d739f1e13f029b datatable feedbacks.rb https://gist.github.com/anonymous/823ce636c5f4fb8cdc8e42557ec6353b What is the problem ? |
Rails, "undefined method `variant' for nil:NilClass" on render json Posted: 03 Jun 2016 04:37 AM PDT I am trying to do something really simple, render a json with some stuff. I do have a view views/api/initialize.html.erb if this counts as useful info. I have no idea what causes this but the variables filled alright, I checked My controller: My route:
Here is my full error trace from development.log: Can you locate where the problem is here? Thank you. |
How can show current_user's friends' posts and what's popular in one record? Posted: 03 Jun 2016 04:19 AM PDT I have set up my scopes and all are working as expected but I could find a way to filter the friends posts in one scope. In the model In the controller How can I add the following/friend filtering for a scope so i can merge them with other scopes. I'm trying to make the page display posts with more than 20 likes and also display friends' posts even if they're not above 20. Thanks in advance. |
undefined method contact_path in rails form Posted: 03 Jun 2016 05:02 AM PDT I have my routes defined as below And in my ContactsController I have defined as below In views contacts/new/_form.html.erb I have structured form as below But when i go to localhost:3000/contacts/new I get the below error. undefined method contacts_path which is occuring in first line of form. But when i try to define as below in routes, it worked Any idea why rails throws such error when i have defined it in the routes file. I am just trying to understand inner workings of rails routes |
Ruby on Rails - Adding sort order to album images Posted: 03 Jun 2016 04:09 AM PDT I am creating a users album application. User can upload many images into their album and I am using In my view when user is seeing the images that belongs to the album I want to show X of (total_number_of_images). For ex: if a album has 12 images and user is seeing the 3rd image in that album, it would be 3 of 12 and when they click on next it would change to 4 of 12, etc. How can I get this to work? Do I need to add a This is what I have done until now: I have added a This actually adds increment to Its has to be: As you can see its on wrong order. |
Posted: 03 Jun 2016 03:39 AM PDT If I want to build web application that the server side will be in ruby on rails, I need to learn ruby language in order to that? I need to mentioned that I am new to ruby and to ruby on rails. In addition I will be happy for a short explanation what I need to do first in order to do the right steps. Thanks!!! |
Posted: 03 Jun 2016 06:41 AM PDT I have created RAILS API where I am sending Boolean value True(true) or False(false). Application works fine if I send "true" value in boolean field but it throws error message i.e "Filed can't be null" if I pass "false". Please find the below example- { "Product": {"Name": "product1" , "Active":false} } { "Active": [ "can't be blank" ] } { "Product": {"Name": "product1" , "Active":true} } success Message |
binding_of_caller gem error in Rails 3.2.13 Posted: 03 Jun 2016 05:26 AM PDT I am working on Rails 3.2.1 application and this is my Gemfile: While running bundle install, I got the following error:
With some R & D, I run bundle update binding_of_caller, this time it's different error:
|
Rails_Admin select tag for n-n association Posted: 03 Jun 2016 03:25 AM PDT I have 3 models: Explanation:
What I'm Looking for:In the rails_admin gem, HTML elements that represent the fields are automagically supplied by inferring the data type and association used. Since AddressType has_and_belongs_to_many Address, the automatic fields that are being shown is this: Notice that when you create a new AddressType record, you are allowed to add 1 or more addresses. How can I replace the n-n widget with a select tag? I already used the enumeration smart default approach like this: It actually shows up, but it doesn't save. It throws an error. |
Ruby cannot JSON.parse(file.to_json) Posted: 03 Jun 2016 05:40 AM PDT I have a hash in a text file, but I'm getting a JSONParseError 757 when I run the below command. However, my test works when I manually type in the hash i.e. Any ideas? |
Rails: How to start thin server in ssl Posted: 03 Jun 2016 03:03 AM PDT I am trying to start thin serve on https protocol but getting below error. Below is the command that i am using for thin server to start thin server in https Below is the error that i am getting. |
Rails error while migrating to heroku Posted: 03 Jun 2016 02:58 AM PDT when I try to migrate to heroku by heroku run rake I get: Running rake on ⬢ friends-clique... up, run.8185 /app/vendor/bundle/ruby/2.2.0/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.rb:2: warning: already initialized constant Bootstrap::VERSION /app/vendor/bundle/ruby/2.2.0/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/version.rb:2: warning: previous definition of VERSION was here /app/vendor/bundle/ruby/2.2.0/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.rb:3: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA /app/vendor/bundle/ruby/2.2.0/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/version.rb:3: warning: previous definition of BOOTSTRAP_SHA was here DEPRECATION WARNING: The configuration option I thought heroku runs in production mode , What just happened . |
Redirect_to not working as expected Posted: 03 Jun 2016 03:10 AM PDT I'm creating a checkbox with Ajax call to update an attribute... everything is working fine but my redirects aren't working as intended (nor flash[:notices]) If i use chrome Network i can see the GET method for the desired page but no redirect whatsoever and flash[:notices] don't work (I'm assuming it's related) So Here's my code: Controller : View: Javascript Routes Ok So everything works as intended... Problem is i want to show a message when user activates 3 checkboxes but Flash Notices and redirects aren't working... Can someone explain to me why? |
Posted: 03 Jun 2016 06:56 AM PDT How can i separate styles for different models? I have my
also i have two models witch use this styles
and
so i want to use
and Is it possible? |
Rails: Provide default value for the disabled select helper Posted: 03 Jun 2016 02:54 AM PDT I have a select helper as seen below, I have disabled it and would like give "1" as default value, but couldnt find how? It is disabled so it should select 1 as default. EDIT I see that it works from the console; but it does not send as params, when I take out disable true and select value send the form, it works.. EDIT2 anyways, I have solved it by giving only one select value as; |
Rails, a way to render everything my app has in one json? Posted: 03 Jun 2016 04:36 AM PDT I want to render everything my app has to json, so I can pass it to android studio. I have a general controller and a method initialize and I want to pass everything from there. I know it's probably a starter's question but I can't find a simple example to see how this works. Or I'm not searching right. Do I need a gem, or I can do that with *render :json => @data * or something similar? Thanks. |
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