change column type to integer rails | Fixed issues |
- change column type to integer rails
- How to get rid of additional spaces using redcarpet gem (Ruby on Rails)
- Deleting multiple records based on specific conditions in rails 4
- How to group_by this array of hashs (Enumerable) [Ruby, Rails]
- Validate that option is selected before progressing
- rails undefined method `id' for nil:NilClass with belongs to relationship
- POST 500 (Internal Server Error) using Ajax, React and Rails
- Rails one to many confusion
- Alchemy CMS: Create element that contains list of elements
- Preventing SQL Injection in Rails while using Javascript Query Builder
- How do I achieve single sign on and data sharing across 2 rails apps?
- Rails 5.0.0beta3: ActionController::InvalidAuthenticityToken in development
- why mock data while testing?
- How to render error messages for a json form in Rails
- wicked_pdf gem + Highcharts
- Why this route goes to the show action
- I can't do heroku push. ruby on rails
- how to manage users by an admin in ruby on rails
- Unable to trigger action to controller with websocket-rails gem
- Rails 5 get users_path(10) test doesn't fail even no "show" method defined in controller
- Rails: Assigning another user to an excisting entry (associations)
- Rails 4 not able to get the actual website url stored in the database
- Why is the Farday request not picking up the change in path?
- Rails 5: how to use $(document).ready() with turbo-links
- Rails: Allow users only to get points only once. (Prevent users from refreshing page and get points again)
- Why aren't my scss files communicating with each other? [duplicate]
- Devise Registration form is still creating a user despite Stripe not being valid RUBY
- Hearing in Rails Syntax Error
- Specific SoundCloud songs do not load artwork and prevent functions of my web app to crash?
- Cannot send email with paramter(id) to my domain's email
change column type to integer rails Posted: 20 Mar 2016 06:33 AM PDT I have run a migration when trying to change on heroku table column from string to integer: This is my migration: And this is my error: What do I do? |
How to get rid of additional spaces using redcarpet gem (Ruby on Rails) Posted: 20 Mar 2016 06:35 AM PDT I'm trying to write blog using markdown, and decided to install redcarpet gem. Everything looks fine, pygments.rb are doing great job with syntax highlighting, BUT the problem is, whenever I try to put block of code using application_helper.rb Post view - show.html.haml This is how code looks like in sublime: This is how rendered post looks like with copy-pasted the same code to post content: I'm using SublimeText3 with 2 spaces indentation, views are in html.haml format. This is the exact input of post content: |
Deleting multiple records based on specific conditions in rails 4 Posted: 20 Mar 2016 06:40 AM PDT Im trying to create a button that will delete all expired records from the database, but not sure exactly as to how to achieve this. I think I got the controller part set up correctly, but im not sure what to put in the routes and the code for the button itself to delete the desired records. This is what I have in my controller: |
How to group_by this array of hashs (Enumerable) [Ruby, Rails] Posted: 20 Mar 2016 06:55 AM PDT I have an array (@items) of hashs with this structure: @items: And the My code: But this doesnt group at all. I'm looking for a result like this:
Solution: |
Validate that option is selected before progressing Posted: 20 Mar 2016 06:14 AM PDT I have the following options within a form: I want to require the user to select one of these options before progressing. I have entered |
rails undefined method `id' for nil:NilClass with belongs to relationship Posted: 20 Mar 2016 06:16 AM PDT This is my item model: This is my prop model ( porp is short from property) I have this problem. When I create prop I require item_id. But if there is no item with this id I will get an error here: What do I do? UPD:I can check its existence like |
POST 500 (Internal Server Error) using Ajax, React and Rails Posted: 20 Mar 2016 06:12 AM PDT I'm just taking a step to use Ajax so I may missed something very important. Instead of having the page to refresh, I now want to use ajax. I'm testing a small code but the browser console says:
Routes: .jsx: foo_controller.rb: Looking at my rails console, the user's age was set to 99. Anything I've missed in my ajax learning? |
Posted: 20 Mar 2016 05:53 AM PDT I'm trying to wrap my head around associations in Rails. I come from iOS development background. I have a basic one-to-many working I think but I feel like I'm doing it wrong, so I'm asking on here to make sure. So far, I have user.rb cat.rb I have generated my migration like so: Migration file Route.rb When user go to QuestionFirst of all, is this the correct way to fetch all cats for a user ? It just doesn't feel right... Coming from an iOS development background and using CoreData, I am used to being able to do something like: and but my initial encounter with Ruby on Rails and ActiveRecords doesn't seem to suggest so. Is it possible for Rails to do what is shown above? |
Alchemy CMS: Create element that contains list of elements Posted: 20 Mar 2016 05:39 AM PDT I'd like to create an element which can contain a list of items, where each item can have more than one essences. For example: The user should be able to add a "page listing" as content element. For each page item he should be able to upload a small image, a short description and a link. Because the list needs to be wrapped with an Other example: The user should be able to add a "team listing" as content element. Each member having a photo, a name, a job description and an email address. Same problem here: I'd like to have the team members wrapped within an Is there some way of releasing elements which can contain elements? Some kind like: (just an example, might contain bugs) The inner item uses the default editor for pictures or text essences. If someone knows a way how to realize this it would be very great, because it's the last puzzle part which is missing in order to use alchemy CMS :( Thank you in advance |
Preventing SQL Injection in Rails while using Javascript Query Builder Posted: 20 Mar 2016 05:08 AM PDT I would like to use jQuery query builder as a tool in a multi-user app: http://mistic100.github.io/jQuery-QueryBuilder/ I understand using such an tool could potentially carry great risks for SQL injection if not setup properly. I am aware of the traditional methods of preventing against SQL injection (i.e. hardcoding the WHERE statement rather than inserting user-inputed strings directly in), but in this case that would prove to be a bit more difficult given how dynamic and flexible we are trying to keep things. I am wondering if there are any easy ways to setup a secure process while using something like this query builder. The main concern is one user being able to access and/or modify another user's records (I am not as concerned about them messing with their own records, but they're all in the same database). One idea I had is doing a find and replace for any problematic words (i.e. DROP, etc), but I understand this would place limitations on user-input (i.e. if they wanted to search records that matched "He dropped the ball")...and also is perhaps not foolproof. Are there any other methods that might work, short of having to code in some complicated algorithm to generate SQL code server side? |
How do I achieve single sign on and data sharing across 2 rails apps? Posted: 20 Mar 2016 04:46 AM PDT I am looking to set up 2 rails apps (with the same tld) which have single sign on and share some user data. If I have railsapp.com I will have the second app set up as otherapp.railsapp.com or railsapp.com/otherapp. I will most likely have railsapp.com handle registration/login etc (open to suggestion if this is not the best solution). So lets say I sign up and upload an avatar and start accumulating user points on the main-app, I can then browse to the other-app and my profile there has the correct avatar and points total. is there an easy way to achieve this? Do the available SSO solutions create the user in the second app with the same user ID? if not, how are they tied together? (ie how can I query the other app for information I would like to be shared across the 2 - user points and avatar) I was initially looking at sharing a database or at least the user table between the 2 apps, but I can't help thinking there must be an easier solution? |
Rails 5.0.0beta3: ActionController::InvalidAuthenticityToken in development Posted: 20 Mar 2016 06:04 AM PDT I have just started a simple app with a couple of forms on Rails 5.0.0beta3. In development, using http://localhost:3000 on Safari or Chrome to access the app, if I fill a form and submit it I always get an The app uses the defaults:
Example: Log: It works fine if I disable per form CSRF tokens in the controller ( The session does not seem to be reset at any point. Interestingly, when the form is first loaded, the authenticity token in the header's menage tag is different from the token in the form. The meta tag is also at the bottom of the header's tags. When I then reload the tokens are the same in both the meta tag and the form, and the meta tag is at the top of the header's tags. |
Posted: 20 Mar 2016 05:29 AM PDT I'm trying to learn some testing, and stumbled upon mocking and stubbing. I actually think I can get the difference here, point I can't think of any reason i should use mocking in the first place. Lets look at the example code from Mocha gem documentation: I dont understand the reason behind this line: Whether I use it or not, the output is completely the same: the test passes. I can feel that it has something to do with telling the object/class how to behave, but how is that testing if we first tell the object to return true and then check if it returns true? It always will, we told it to. Isn't it pointless? |
How to render error messages for a json form in Rails Posted: 20 Mar 2016 02:36 AM PDT I'm trying to display error messages for a failed from submit on an ajax form. I haven't gone down the path of ajax forms before and cant find a solid upto date guide on how to get error messages to show when the form fails to save the data for whatever reason. I have category_item_keys controller new.html.erb category_item_key.coffee I've read over all the posts I can find to see what needs to go in category_item_key.coffee but they are all 3-5 years old and just don't work. I'm sure its not that complicated but I don't know much about JS to get it working. |
Posted: 20 Mar 2016 02:28 AM PDT I read some answers, but didnt solve my problem. Html charts works good, but when I export to PDF with wicked_pdf charts doesnt show. I set chart options : And tried giving javascript delay. I tried including and not including in my layout the jquery and/or highcharts js files again according to some posts I read. But nothing is working for me , my wkhtmltopdf library version is : All answers I read are 2+ years old so maybe someone can help me with a newer method. |
Why this route goes to the show action Posted: 20 Mar 2016 02:59 AM PDT This request goes to SHOW action in Webservices controller.. This goes where I wanted at getsomething action ... rake routes : and still rails go in show action ??? |
I can't do heroku push. ruby on rails Posted: 20 Mar 2016 02:22 AM PDT I did So I did I don't know how to fix this issue and push heroku well. need your help! |
how to manage users by an admin in ruby on rails Posted: 20 Mar 2016 03:08 AM PDT how can I manage and edit other users profiles as an admin since I have one model and controller (users) ? I tried to add a new action called updateusers
stack trace |
Unable to trigger action to controller with websocket-rails gem Posted: 20 Mar 2016 01:40 AM PDT I've created a new empty Rails 4.2 app. Then added just It doesn't work neither in standalone mode nor otherwise (I want to run it in a standalone mode). There're no errors when I start websocket_server. There're no errors in You could find the app source here https://github.com/poyzn/websocket-rails-test-app. Trying to run it in development, rvm 1.26.11, ruby 2.1.5, rails 4.2, redis server 3.0.4 |
Rails 5 get users_path(10) test doesn't fail even no "show" method defined in controller Posted: 20 Mar 2016 02:21 AM PDT Me gain, yes. Got a weird problem. This test should fail but it isn't. Using Rails 5 --api only. Got a UsersController like so: Test file:
The console output: Why is the test not reporting error when the controller clearly has no Going to my browser localhost:3000/users/10 returns JSON saying "show" method does not exists. Any ideas? |
Rails: Assigning another user to an excisting entry (associations) Posted: 20 Mar 2016 01:08 AM PDT I have 2 models in my project. 1 is Users and 1 is courses. A user has many courses and courses has many users. The main problem is that I can't figure out how to assign users to courses without creating a new course. My output would then be something like Now I can't figure out how to add another user to this same course. |
Rails 4 not able to get the actual website url stored in the database Posted: 20 Mar 2016 12:27 AM PDT I have a string field in my User table where I store the user's github website url. Now, I am trying to show the link on the user's profile page. Instead of getting 'https://www.github.com'(example link)...I am getting "localhost/users/www.github.com". I tried it the following way :- On clicking the link, I get localhost/users/www.github.com instead of just www.github.com. How can this be done correctly ? |
Why is the Farday request not picking up the change in path? Posted: 20 Mar 2016 12:09 AM PDT I'm doing an exploratory code reading of a gem....If I change this line of code in the airbrake api gem to: and change this line to: and change this line (and change the corresponding function parameter of @client.notices to accomodate the extra parameters, not showing here for brevity) to: I still get this error: Why does Faraday not seem to pick up the /api/v4 part of the path? I have a feeling the issue is in the request method here... |
Rails 5: how to use $(document).ready() with turbo-links Posted: 19 Mar 2016 11:15 PM PDT |
Posted: 19 Mar 2016 11:18 PM PDT I am creating a course system in rails and I want to award users points for completing a certain task but I want to avoid that the users can refresh the page and get the points again. My controller looks like this: What is the easiest way to make a boolean or similar system that checks if the user was already awarded theses points and if not reward them. |
Why aren't my scss files communicating with each other? [duplicate] Posted: 19 Mar 2016 10:43 PM PDT This question is an exact duplicate of: I'm having trouble with variables in one SCSS file not loading into another. I made a previous post here What's causing this SASS::Syntax error? regarding the issue and decided to just make a new post all together as I've figured out a little more about the issue. To try eliminating the problem I replaced the variable
with the hex code of the color I wanted to display and got the same undefined variable error with the next color variable on the list. I replaced all the color variables and I got the error once again with the font variable further down the file. All of these variables are in the file
The paths to these files are
The "spree_admin.scss" is the file that loads all the stylesheets for the backend and looks like this. I also tried adding the underscore before the names and the SCSS file extension to the end of the files but that still didn't make a difference. As I said in the original post, everything was fine before I went to bed. I was clicking all the links making sure everything looked the way I wanted it to look. Yesterday when I woke up I went to work on it some more but after I started the rails server and went to localhost:3000 in the browser I got the undefined variable error. For some reason the "_bootstrap_custom.scss" file isn't reading the variables of the "_variables.scss" file. There's other changes I made to other files that I know are picking up on those variables, so they're being read in, it just doesn't communicate with the bootstrap file for some reason. any idea why? |
Devise Registration form is still creating a user despite Stripe not being valid RUBY Posted: 19 Mar 2016 10:22 PM PDT I am using Devise to manage Users and am using Stripe to set up 3 seperate subscription plans. However, when the Stripe fields are empty or invalid, it will flash an error screen and still create a new User except without a Plan ID The registration controller looks like this. The following is the model I am using for my User. |
Posted: 19 Mar 2016 10:06 PM PDT New to Rails, trying to add a favorites, using hearts on posts in my app and dont know why I'm getting this sytax error. Have followed the tutorial step by step.Is this somethong obvious ? /Users/leehumphreys/Desktop/with hearts favorites/app/views/rooms/show.html.erb:292: unterminated string meets end of file /Users/leehumphreys/Desktop/with hearts favorites/app/views/rooms/show.html.erb:292: syntax error, unexpected end-of-input, expecting ')' Actually getting the error at <% @rooms.each do |room| %> |
Specific SoundCloud songs do not load artwork and prevent functions of my web app to crash? Posted: 19 Mar 2016 08:59 PM PDT I am building a web app of which theres is a function that renders a queue of SoundCloud tracks. Theres is a compiled list of SoundCloud IDs, on click it redirects to home and appends those IDs into the user's queue. I am noticing specific SoundCloud tracks that prevent this process from occurring, causing the reload to be incomplete. When I manually reload, most of the tracks are there, however specific ones are missing their artwork. They can still be played manually on click. I have noticed that if I remove the IDs with "missing artwork" the queue loads fine. All ID's are valid, I am not getting a 404 on any requests. The Heroku logs do not show anything unusual, they show a 200 on the requests to create the queue. There is no SoundCloud documentation on this. I am starting to think it is a SoundCloud error, but I would like to know if anyone has seen this or if there is a solution. Link to web app: www.songtrast.com |
Cannot send email with paramter(id) to my domain's email Posted: 20 Mar 2016 01:21 AM PDT I have a domain which I have purchased with Godaddy. I have setup Office 365 email with this domain so that my app or other people could send email by using this domain email. Right now, I am able to send all email to this domain just fine. But when I try to test to put some parameter(id) onto the address, the email is failed to be sent. I need to be able to make this work as I need to use this domain email for my rails app. This is example of email address with the id that i am trying to send to: And this is the error that I received: I have tried this with my gmail and gmail completely ignore the "+" sign and the parameter that I supplied and send/receive the email just fine. But when I tried it on my domain, it failed to be sent. Do I need to setup something? Please help! 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 |
Your blog is in a convincing manner, thanks for sharing such an information with lots of your effort and time
ReplyDeleteruby on rails training
ruby on rails training India
ruby on rails training Hyderabad