Building Rails Forms for saving Polymorphic Associations | Fixed issues |
- Building Rails Forms for saving Polymorphic Associations
- AJAX delete not working when sending information to rails server
- Nested namespaces in rails error accessing model with same name as namespace
- Response from Servers... Connection to http://192.168.3.11:3000 refused
- Error when trying to open gitignore
- omniauth-facebook+devise callback does not get executed
- Rails 5 - sending data from controller to javascript in json format [on hold]
- No route matches [GET] "/contato"
- find events within date range of search results in rails/ruby
- Rails link_to polymorphic parent, which can have a nested route
- Rails - scope for records where not in join table
- After changing from sqlite to postgres (rails) destroy and edit are not working for my projects
- What does yield inside a controller action do?
- RAILS Auto refresh partial
- Review Reputation System
- ActiveView::Template::Error ( uninitialized constant CustomBreadcrumbsBuilder )
- How do I delete images of some versions on carrierwave?
- Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 34 column 4
- Getting count of entries for a sub-model with date filtering in Rails
- Ruby on Rails: Validating rendered HTML with MiniTest
- Rails: Ensure password is present if password_confirmation is given
- Ruby on Rails Scaffolds Community Resource
- Ruby on Rails: Cant figure out why my jQuery-ui autocomplete isn't working?
- devise-token-auth causing trouble in api namespace
- How to check if Ajax request was sent in Capybara Rspec?
- How should i add header to HTTP GET request using ruby
- Which type of token auth is more secure for api?
- How to use TCPServer in Ruby on Rails?
- give value in rails form's label element in rails
- Adding Jquery click handler to dynamically-loaded content
Building Rails Forms for saving Polymorphic Associations Posted: 10 Sep 2016 08:17 AM PDT I have categories model which I would like to be able to use with different models. That's how I ended up using Polymorphic with has_many. With Rails_admin everything works without a problem. But, when I want to create a form by myself, I can't seem to make it save. Here is what I have: category.rb categorizing.rb car.rb vendor.rb cars_controller.rb This is what I have in the form And I receive this error: Unpermitted parameter: category_ids I am very confused right now and lost in models. Dont know this is the best approach or not. I would be glad if someone could tell me where I do the mistake. |
AJAX delete not working when sending information to rails server Posted: 10 Sep 2016 08:10 AM PDT I am trying to make an ajax delete request to my rails backend server but i keep getting an error: XMLHttpRequest cannot load localhost:3000/teams/1/articles/36/comments/161. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. my ajax request: im following the correct routing path in rails: My cors is set up as such: And my controller: what i dont get is that error is saying it cant load the url but, type: 'delete' in the ajax call should tell the backend its a delete request shouldn't it? |
Nested namespaces in rails error accessing model with same name as namespace Posted: 10 Sep 2016 08:08 AM PDT I have a To improve my design i introduced additional name spaces for sub resources. So to list all the customers for one specific manager i have a customer controller under the manager name space. There all actions specific to a manager related to a customer resource are going. The routes.rb entry looks now like this When testing the new setup i receive now this error When i replace the |
Response from Servers... Connection to http://192.168.3.11:3000 refused Posted: 10 Sep 2016 07:49 AM PDT Ruby version 2.2.4 Rails version 5.0.0.1 Hello People, I have programmed an android app, which can take profile pictures from a user. Now I want to upload these profile picture to my Ruby on Rail server. However the upload doesn't work. I receive the Error message: Here is the host-adress I use in my android-app. I use my local ip-adress so this part should be correct. And this is my ruby on rails app: items_controller models/item.rb uploaders/picture_uploader.rb routes.rb Did I miss something in my ruby on rails app? How can I send my images from android to Ruby on Rails? Do I need extra software for uploading like a WAMP server? I am totally new to this stuff |
Error when trying to open gitignore Posted: 10 Sep 2016 07:51 AM PDT I am working on a ruby on rails application. I use the Cloud9 online IDE, which is Ubuntu. When I go to the root directory, I can't open my .gitignore file. I know I'm in the right spot because when I'm in root and I type I've seen other threads and some suggest using either open or see, followed by .gitignore. And they always work for OP. But neither of them work for me. I tried this one: But when I use that, I get the following error: And when I use this command: I get the following error: If anyone has any idea what's going on, please help me out. I can't find any other fix from other threads, other than using the two commands above. |
omniauth-facebook+devise callback does not get executed Posted: 10 Sep 2016 06:49 AM PDT I have implemented devise and omniauth-facebook following the instructions below: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview Problem My "facebook" callback function does get called. If I uncomment the "facebook" function, error occurs. Routing seems to be working fine However, the code inside the function does not seem to be executed. The following code does not raise any error. I have been looking in to this problem for days. Please help... Log Versions |
Rails 5 - sending data from controller to javascript in json format [on hold] Posted: 10 Sep 2016 06:45 AM PDT I want to be able to send an array of object to my Google Maps, so I can display the locations. What I want to ask is what is the best way to do it? I was trying to use RABL gem but the tutorials they have are not exactly up to date. Then I found info about building and API using rails. This seems like a good plan, but I have no idea how to use it. Google is filled with tuts but only for building API-only app, and I already have my app and just want to add an API to it. Where should I start looking for it? |
No route matches [GET] "/contato" Posted: 10 Sep 2016 06:42 AM PDT I'd like to do a contact form, but I'm get a routing error. My view (contato.html.erb): My controller (pages_controller.erb): class PagesController < ApplicationController Routes: Rake routes: |
find events within date range of search results in rails/ruby Posted: 10 Sep 2016 07:24 AM PDT I'm struggling a bit to get this to work, I have a working search function on my website using searchkick. However i'm wanting to allow my users to filter the results on the results page. This is my controller for reference: Now what i'm wanting is a simple date picker in the view, that allows the users to search a date range (to and from) of the events returned then on submit it would return only the events in that range. I've looked at filterrific but got confused and wasnt sure thats what i actually need? Any help would be much appreciated! edit So if i have this: I'm wondering what i need to put on the button, And also would the bit in the controller go into the Thanks |
Rails link_to polymorphic parent, which can have a nested route Posted: 10 Sep 2016 07:15 AM PDT I have the Comment model, which is polymorphic associated to commentable models like Project, User, Update etc. And I have a page where a user can see every User's comment. I want a link near each comment with an address of an object this comment is associated with. I could write something like that: But this will work only for not nested routes (like User). Here's how my routes look like: So when I need a link to a Project page, I will get an error, because I need a link like user_project_path. How can I make Rails to generate a proper link? Somehow I have to find out if this object's route is nested or not and find a parent route for nested ones |
Rails - scope for records where not in join table Posted: 10 Sep 2016 06:07 AM PDT I have two models - I have lots of Tournaments, and each one can have lots of Players. Players can play in lots of Tournaments. The scope successfuly finds all the players already added to a tournament, given that tournament as an argument. What I'd like is a scope that does the opposite - returns all the players not yet added to a given tournament. I've tried but that returns all the players. I've tried the suggestions on this question - using |
After changing from sqlite to postgres (rails) destroy and edit are not working for my projects Posted: 10 Sep 2016 07:41 AM PDT So I am making a website(portfolio) for my projects, wich has Projects, Contact, and a Devlog, in order for people to be able to follow my work and progress, but when I changed to postgres deployed to heroku somehow edit and destoy are no longer working. Errors I am guetting EDIT: DESTROY: This one appearently is trying to delete the posts (wich are my devlogs) This is my Index of projects This is my "show" And this is my controller for projects I do not know if you need anything else, to help me out, but please ask if the info is needed. |
What does yield inside a controller action do? Posted: 10 Sep 2016 05:13 AM PDT I was looking through the Devise code and noticed that most of the controllers yield the resource being created. This must be some sort of extendability feature but I don't really get how you would pass a block to to the controller action? Note: This question is about how you would actually do in the Rails request cycle, not about how blocks in Ruby work. |
Posted: 10 Sep 2016 06:06 AM PDT I have a controller events with action show : In view show.html.erb i have The javascript function call controller method events/reload_requests : And content of partial _requests.html.erb : Problem : The javascript function load all the content of my show.html.erb page in div #requests, but in the copy of show.html.erb in the div, it refresh div #request correctly : enter image description here You can see, in show#requests i have the content of show. Than you |
Posted: 10 Sep 2016 04:53 AM PDT I am trying to integrate review reputation to my existing rails application. A user can leave a review to a model with start rating by category, review title, review body, and with photos along; examples similarly to Amazon Customer Reviews, Airbnb Host Reviews or Shop Oreilly customer reviews. Moreover, I figured out there is 'Was this review helpful for you?' for a review. I also want to have this along with each review in my application. Yet, I only found Twitter Does anybody here have experience with such review reputation system using Ruby on Rails? Please help share your ideas and experience below. I appreciate your help in advance. |
ActiveView::Template::Error ( uninitialized constant CustomBreadcrumbsBuilder ) Posted: 10 Sep 2016 03:55 AM PDT I'm using a gem called And I'm using this class in It successfully loads the file in development environment, but in production, it's producing the following error: I have tried the following things: Added following to my And But none of thing is working. Again, it is working in development mode, but fails in production. I'm using Rails 5.0.0, and ruby 2.2.3, and on production, I'm using Puma and Nginx to serve the requests. |
How do I delete images of some versions on carrierwave? Posted: 10 Sep 2016 03:39 AM PDT I use carrierwave. Recently I figured out how to recreate other visions using recreate_versions! something like this But I realized this method just creates new versions, it does not delete previous version's images. Is there method that deletes images that version do not exist? |
Posted: 10 Sep 2016 04:00 AM PDT I am geeting Below Error when trying to find the particular record and i have also used serialize :value 2.0.0-p598 :003 > Model.find(123) from /home/linux3/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/psych.rb:205:in |
Getting count of entries for a sub-model with date filtering in Rails Posted: 10 Sep 2016 04:36 AM PDT I want to get count of objects for a sub-model in Rails with date filtering. Let's explain in detail:Assume that I have two models.
Also the I want to get comments count for each post by date range. For example; I want to get only today's counts. Does anyone have an idea that how can I do it without many DB queries? Is it possible with counter cache? |
Ruby on Rails: Validating rendered HTML with MiniTest Posted: 10 Sep 2016 03:56 AM PDT I'm going through the Ruby on Rails Tutorial and I'm surprised that there is no mention of validating the HTML produced. How does one validate HTML with Rails' MiniTest? I'm after a local solution, not something which uses W3C's Markup Validation Service - this is too slow if I honour their request for maximum one hit per second. |
Rails: Ensure password is present if password_confirmation is given Posted: 10 Sep 2016 02:32 AM PDT I'm working through the Ruby on Rails Tutorial and in the exercises for 10.1.2 - Unsuccessful Edits I'm being asked to test that the application correctly catches invalid form submissions. Perhaps I did the exercise too thoroughly - I've found that it's "valid" to submit a I thought that 1) Why doesn't it? 2) How do I ensure that if I currently have: I've tried adding |
Ruby on Rails Scaffolds Community Resource Posted: 10 Sep 2016 01:38 AM PDT I'm a noob to rails, and am learning some of its cool features. I'm really impressed by the scaffolds - they seem to be generic frameworks for things like blogs etc. Is there a community resource where other scaffolds can be found? I'd like, for instance, to create a site that has an image slideshow or similar where a user can log in and upload photos to add to the slideshow and delete existing images or change the order or effects, time etc. I'm sure that I can amend the Posts scaffold to do something along these lines, like I say I'm a noob at the moment and learning by doing is good, but I see that there is a way of making your own scaffolds, so I wondered if some kind person had made any scaffolds available. Many thanks... |
Ruby on Rails: Cant figure out why my jQuery-ui autocomplete isn't working? Posted: 10 Sep 2016 03:01 AM PDT I just followed a youtube tutorial on adding a jQuery-ui autocomplete feature to my search field. This is the link to the tutorial: https://www.youtube.com/watch?v=iMz8HmrQ350. For some reason it is not working, despite going over the tutorial and rechecking syntax constantly. I'm NOT getting any errors when I reload the web browser, however, nothing appears as a drop down menu as I type in the search field. Interestingly though, if I use an array for sample data, it works (the drop down menu appears with suggestions using the sample array data). But when I try to link it to my database of posts, it no longer works. I have shown example code for both ways below. My code is below - any help is much appreciated i've been trying to add this feature for a while attempting countless tutorials and methods. It's getting annoying haha. I am new to coding and have taught myself thus far. Please let me know if any other files are required. PS. I'm currently using elastic search and search kick for a simple search. Could that possibly have anything to do with the autocomplete feature not working? I'm also using the gem: "gem 'query-ui-rails'" in my gem file incase that is important to know. posts.coffee search_suggestions_controller.rb IF I USE AN ARRAY AS SAMPLE DATA, IT WORKS - EXAMPLE: MODEL: search_suggestion.rb TASK FILE: search_suggestions.rake |
devise-token-auth causing trouble in api namespace Posted: 10 Sep 2016 12:58 AM PDT devise-token-auth just works fine when I DONT have the api namespace with controllers nested inside However this doesn't seem to happen when I run my server with controllers not nested inside api, and if i move controller file to it works like before surprisingly! except I get this error very similar to this SO post after every And how to get it working without |
How to check if Ajax request was sent in Capybara Rspec? Posted: 10 Sep 2016 12:52 AM PDT I have a search interface with instant search as you type. It is optimized to send AJAX requests only when they are needed, so I want to test if it does it correctly. How do I check if Ajax request was sent? (any request would be good enough) .. also would be good to check if Ajax request was aborted (in other testcase) |
How should i add header to HTTP GET request using ruby Posted: 10 Sep 2016 03:35 AM PDT Trying to add header in the request The results i have gotten back is I am supposed to get back a list of data in json. I tried using postman to test if the url is working and passed the email and token inside header and i got back the data that i wanted. I am not sure where it went wrong with the code. Can anybody advise me which part did i do wrongly? Thanks a lot! |
Which type of token auth is more secure for api? Posted: 10 Sep 2016 12:28 AM PDT I am confused if I should choose between devise-token-auth (issues new tokens for each request) or knock (issues a json web token once and keeps using it till it expires or user signs in again)
Is continuously issuing tokens possible in case of JWT and is it worth doing it? (Like making the server issue a new token with a new expiry after each request) PS: I just came across these two libs for Rails for effectively managing tokens integrating with devise. If there's a better one - which typically one would use for ecommerce like APIs - I'm open to using that. |
How to use TCPServer in Ruby on Rails? Posted: 09 Sep 2016 11:38 PM PDT I am using Ruby on Rails on Cloud9 IDE I have to transmit data between server and GPS device. I put on device and did code like below. My_Controller when i ran this i got Kindly, help me how to solve this problem.. Thanks in advance. |
give value in rails form's label element in rails Posted: 09 Sep 2016 11:35 PM PDT I have a label in my app like below. Now to the label shipping_destination, I want to give a dynamic value coming from spree, which is How do I pass this as a value to the label? |
Adding Jquery click handler to dynamically-loaded content Posted: 10 Sep 2016 01:37 AM PDT My Rails app loads links to a page dynamically. I want to append an The links are appended to the page properly, but the JS for the page is not being applied to those newly added elements. I've tried rendering new JS tags to the dynamically-added content. I've also tried including this block of code, which should target any link with That code works when the links are not dynamically loaded. However, I cannot seem to apply ANY onClick handler to them when dynamically loaded, even in the console. What could possibly cause this issue? For more context, the problem I'm trying to solve is here: AJAX-loaded JS not rendering |
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 |
I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.
ReplyDeletesenior citizen saving scheme