Rails: How to customise the order of fields in a form with nested fields | Fixed issues |
- Rails: How to customise the order of fields in a form with nested fields
- How to asynchronously send JS variable to Rails
- Rails production log level
- why is AccessDenied returned for only some images in an S3 bucket?
- Rails 4.2 Expire fragment cache
- Rails migration error - table not showing in schema.rb
- Dynamically passing ids using slim instead of erb in ruby on rails
- PostgreSQL data types excluding those for the row structure of tables
- Prevent puma from running in locally (ruby on rails)
- Multiple price groups per user per product: how to minimize amount of queries?
- How to Add to cart from external domain using Post Method in Rails
- undefined method `user_url' for Devise SessionsController:create
- Convert Cordova Camera Captured Image File to File Object to save in Rails Application Database
- Having a form for sending emails in rails
- Rails association callback with cached query
- Run method periodically in manualy created interval in Rails
- JSON serialization issue with Ember.js, Rails and Devise
- rails check if a form was completely filled out
- using .where with .find
- Override attr_readonly in data migration to populate a new read only field on existing records
- Solr Sunspot- specify which fields to return in the result
- Stream remote file to client in ruby/rails 4/unicorn/nginx
- subdir in nginx for rails api-app
- Rails, product variants
- Attachinary and javascript form
- Devise login with username, signin failure not showing error message
- Showing User Profile
- How to add the ability to remove upvote or downvote on the second click?
- Timetable App for Rails 4
- Rolling back Model-changes from action
Rails: How to customise the order of fields in a form with nested fields Posted: 15 Apr 2016 06:37 AM PDT I have a form that saves attributes to two models The attributes: In my form I wish to change the order of the fields thus interchanging the I tried the following, but that did not seem to work. How do I make this work? |
How to asynchronously send JS variable to Rails Posted: 15 Apr 2016 06:35 AM PDT Simple HTML form in a view. I need the user selected value of the form to pass into the active record query when the user switches it. (Probably not params because then it won't be asynchronous?) In the example below I need the business_id to be the value of the form. New to rails, so if you could provide some in page javascript, I'll deal with refactoring it to the resources later... |
Posted: 15 Apr 2016 06:49 AM PDT I am using |
why is AccessDenied returned for only some images in an S3 bucket? Posted: 15 Apr 2016 06:25 AM PDT I am using Carrierwave in a Rails app to upload image files to S3. This has been working perfectly for some time. Suddenly newly uploaded files are returning "AccessDenied". This only occurs when accessing the file via Cloudfront CDN references. If the direct S3 url is used, the image displays correctly. I have an access policy and permissions set on the S3 bucket. What is confusing me is why some files are returning Access Denied, whilst others are displaying correctly. Examining the properties in S3, all files have the same permissions and policies, which are set at the bucket level. What per-file settings can be set on S3 that would cause only some files to return Access Denied? And how are those settings configured? |
Rails 4.2 Expire fragment cache Posted: 15 Apr 2016 06:43 AM PDT I am unable to expire a fragment cache. In my view: In the controller's after_action: In my server log: So we can see the expire_cache method is being called and expires the Why hasn't the fragment been properly deleted? |
Rails migration error - table not showing in schema.rb Posted: 15 Apr 2016 06:32 AM PDT One of my model tables (Event) is not showing in the schema.rb file and in its place there is this message - The last migration that was succesful was as follows - Which was changed to this - I'm pretty sure its gone 'wonky' because the attribute shouldn't be a url it should be a string. However, when I try to perform other migrations it doesn't work. I get the following error in my terminal when I try and perform a rake db:migrate - undefined method In my migration files this was my code - I've also tried to remove the column completely in an attempt to then replace it with the correct version but to no avail. All impending help would be appreciated. |
Dynamically passing ids using slim instead of erb in ruby on rails Posted: 15 Apr 2016 06:16 AM PDT Hi I use slim in rails instead of erb. I need to generate dynamic ids based on the id of the record passed to the view page. This is a part of my code: when I try using #clear_class_"#{activity.id}" the view is getting distorted. How can I make this division a dynamic one with my activity id appended to the division id. |
PostgreSQL data types excluding those for the row structure of tables Posted: 15 Apr 2016 05:35 AM PDT We're using Ruby on Rails 4.2.6 and PostgreSQL 9.3.10 for our multi-tenant application which creates a schema for each of our customers. Within ActiveRecord there is code which executes the following SQL to fetch the data types: As this query returns a record relating to the row structure of every table in every schema, the number of records exceeds 150k for our database. For example, for our tags table there is a record for every schema with a typname of "_tags", typinput of "array_in" and typtype of "b". Could anyone recommend a way to alter this query to exclude these row structure records? We have considered using the DISTINCT statement below but this would not cater for two "true" data types with the same name in different schemas. |
Prevent puma from running in locally (ruby on rails) Posted: 15 Apr 2016 05:57 AM PDT I'm recently started to use Puma for my production server with nginx, however, when I now try to run my app locally, it tries to run Puma with all my production settings and fails. How can I prevent Puma from running locally? AFAIK all I've done was added the puma gem to my gemfile, so I don't know how it's accessing my server config (I'm just not too knowledgeable in this area). I have it in my production group: Error: Additionally, though less important to me right now, is it in my benefit to run Puma locally? If so, any tips/resources on how I can do that? |
Multiple price groups per user per product: how to minimize amount of queries? Posted: 15 Apr 2016 06:00 AM PDT I have the following structures in my Rails (4.2) e-commerce application: Many users can be members of many price groups with many product price rows in each of them. There is a default group with default prices for each product plus there can be many optional price groups with special (reduced) product prices for some users. The problem is - this way I'm getting two queries per each product listed in my index page: and So, here is my question: Is there some (easy) way to load everything at once? Like getting list of product objects with default and minimum price fields. I understand how it can be done in a single SQL query, but I can't think of anything more natural, rails-activerecord-way. |
How to Add to cart from external domain using Post Method in Rails Posted: 15 Apr 2016 04:49 AM PDT I have an app which needs to collect various product options and then make a post request to an external url (https://my-shop.myshopify.com/cart/add) and then redirect to that site with the items added to cart. Unfortunately I can't simply use a cart permalink as I need lineitems to be included. So far I have this in my controller which successfully makes the post but doesn't redirect to the shopify site. |
undefined method `user_url' for Devise SessionsController:create Posted: 15 Apr 2016 05:12 AM PDT I have user model for authorization with devise gem. I want to add after_sign_in_path method: Also here is the code it points me: and first line of log: Whenever I commend after_sign_in_path_for I am able to sign in. If I comment contents of after_sign_in_path_for but leave empty after_sign_in_path_for method, I also get this error. EDIT: I tested that I am not also signed in, not just not redirected. I think error happens right in the call after_sign_in_path_for, not in the redirect_to or whatever. Probably it has to do something with resource. EDIT2: here are my rake routes: EDIT3: here is my github repo: |
Convert Cordova Camera Captured Image File to File Object to save in Rails Application Database Posted: 15 Apr 2016 04:34 AM PDT I am developing ionic application where I am using Rails Api for backend. I am uploading file via camera capture plugins cordova-camera and cordova-file. I am getting the file which was stored in android phone cache. I need to upload this file into database along with the form input data. For that I need to convert it to a File Object. For normal input file upload I have use ng-file-upload where it is retreiving file object where I ma saving in it backend sending as param like this: And ng-file-upload File object is lookig like this: I need to save camera captured image as File Object so that I will send this File Object as parameter to rails action to save image in DB along with form input. I have tried like this but no use in angularjs ionic app: Can you please help me out regarding this. |
Having a form for sending emails in rails Posted: 15 Apr 2016 04:39 AM PDT I'm new to rails and was wondering if there was a way to make a form in the views folder so that I can send an email. The form would need an input for: The email address; the subject; message. Then basically you press send and it sends the email |
Rails association callback with cached query Posted: 15 Apr 2016 04:22 AM PDT I have two models: and than I call it like this: The problem: I've investigated the problem and found out that there is some kind of caching in Is there any option to leave the I would like to understand how it works and avoid similar problems in the future. note: I recently upgraded rails from 3.2 to 4.2. In a previous version everything worked fine. |
Run method periodically in manualy created interval in Rails Posted: 15 Apr 2016 04:12 AM PDT I have a form when user can set day in week and time period (for example Monday from 02:00 to 03:00). Then I want to run specific method (periodically, for example every 30 seconds) but only during given time interval (it should be performed on background every Monday during 02:00 and 03:00, every 30 seconds). Is it possible to do this when time interval is created dynamically (by user)? |
JSON serialization issue with Ember.js, Rails and Devise Posted: 15 Apr 2016 04:07 AM PDT I'm struggling to find a way of signing up a new user in my application. I've started using Ember and Rails a month ago and I'm not quite sure where the problem is. I can actually login with Devise and get data from my backend. I can create new instances of any models, except for users. After a week of reading and testing, I believe Devise is not using the user serializer and can't process my request. Here's what I get when I request a new user registration : And when I login: Now here is my Ember serializer: My adapter: And my client side: The funny thing is I tried with the active-model-adapter addon. For some reasons I can register new users and login properly, but findRecord is giving me this error : Here's my gemfile: And finally, my package.json: I feel like I'm missing something obvious, but can't figure out what... |
rails check if a form was completely filled out Posted: 15 Apr 2016 05:53 AM PDT I have information in my rails view that I only want to show up if the user has entered all personal details in the database, such as name, firstname, street and city. I could now do this: but I don't think that is very elegant and "the rails way". Is there an easier and smarter way to do this? |
Posted: 15 Apr 2016 06:41 AM PDT I am wondering how I can use Here is the code I am using: which gives me: |
Override attr_readonly in data migration to populate a new read only field on existing records Posted: 15 Apr 2016 05:03 AM PDT I have added a UUID field to an existing model. I want it to be read only so it cannot be changed. Model: However I want to populate exiting records with UUIDs. I cannot do this through a default value because they are not generated dynamically. I could write a custom validator in the model, but this seems like overkill when I only really want to override the attr_readonly in the data migration. As it stands my data migration does not change the value for existing values from nil. Data Migration: |
Solr Sunspot- specify which fields to return in the result Posted: 15 Apr 2016 05:16 AM PDT I'm using Sunspot Solr for indexing and searching in our Ruby on Rails application with MongoDB database (Mongo mapper) Every time I queried Solr for result, it sends back the entire document content about the article stored in the database, which makes the query very slow. What i want to do is to include only specific fields to the query. I found that fl can be used to specify a set of fields to return but i'm getting an error, see blow: Solr Request : Error :
Thanks. |
Stream remote file to client in ruby/rails 4/unicorn/nginx Posted: 15 Apr 2016 03:45 AM PDT I am trying to stream a file from a remote storage service (not s3 :-)) to the client using Ruby on Rails 4.2. My server needs to stay in the middle of things to authenticate the client request but also to build up the request to the remote storage service since all requests to that service need to be authenticated using a custom header param. This makes it not possible to do a simple redirect_to and let the client download the file directly (but do let me know if this IS in fact possible using rails!). Also I want to keep the url of the file cloaked for the client. Up until now I am using a gem called ZipLine but this also does not work as it still buffers the remote file before sending it to the client. As I am using unicorn/nginx, this might also be due to a setting in either of those two, that prevents proper streaming. As per rails doc's instructions I have tried adding to config/unicorn.rb but to no avail. A solution might be to cache the remote file locally for a certain period and just serve that file. This would make some things easier but also creating new headaches like keeping the remote and cached files in sync, setting the right triggers for cache expiration, etc. So to sum up: 1) How do I accomplish the scenario above? 2) If this is not a intelligent/efficient way of doing things, should I just cache a remote copy? 3) What are your experiences/recommendations in given scenario? I have come across various solutions scattered around the interweb but none inspire a complete solution. Thanks! |
subdir in nginx for rails api-app Posted: 15 Apr 2016 05:02 AM PDT I am trying to configure the nginx to have a separate subdir for rails-5 api backend. (to separate frontend and backend) Original, I am calling backend api under GET "/bills". Now I'd like to be it: GET '/api/bills'. so all requests under 'api' should be redirected to rails app. But I can't make it working. The redirection works, but I see on rails side in logs: here is my current config: |
Posted: 15 Apr 2016 06:16 AM PDT I am building an e-commerce app the hard way(no spree, shoppe, etc) so that I can learn rails. Currently, I have a restaurant model, meals model, and orders model. Users(using devise) can open meals, fill in an order's form with an attribute :quantity and send the order to their carts(keeping :restaurant_id, meal_id, :qty). However, meals in restaurants normally have sizes and supplementals(with cheese, with ketchup, etc.). Ideally, I would build something like spree_flexi_variants but I just can't see how to do this... Should I nest "characteristics" and "supplementals"(becoming 2 levels deep as meals is currently nested in restaurant) in the meals, or somehow add an attribute to the meals model? Thank you guys for any suggestions! |
Attachinary and javascript form Posted: 15 Apr 2016 02:50 AM PDT I have a form like this : My controller looks like this : It works good with the HTML version but not with javascript version. I know that browsers don't allow file upload via XMLHttpRequest, so I find a solution with remotipart gem, but it only considers <%= f.file_field :file %> and not my <%= f.input :photo, as: :attachinary %> |
Devise login with username, signin failure not showing error message Posted: 15 Apr 2016 03:23 AM PDT I have been trying to login with username so followed this tutorial Sign in with username and signup is happening perfectly. But if i try to sign in with invalid username or password, it is not showing any error messages. i have <%= devise_error_messages! %> mentioned in sessions/new.html.erb. Also tried binding.pry resource doesn't have any errors attached to it. routes.rb devise.rb other details same as mentioned in the url. |
Posted: 15 Apr 2016 02:44 AM PDT I've been trying to get this right and after hours I'm finally just lost. I'm attempting to create a profile for a user. I separated the profile model and user model because of the attributes and the types of user's I have. The user has a has_one relationship to the profile. My problem seems to be I'm confused with not only the routes but also the controller of the profile. I simply want to be able to have a link_to to show a user's profile. But on to the code Profile model routes for profile profile controller I'm completely lost on what I need to do, should I add something to the user's controller because of the after_create method? should my resources :profile be under resources :user? The error I get when I try to view a user profile is the link_to method I am using is Please let me know anything that might be of help thank you for your time and help. again I don't want to just show a user's "show" as a profile because of the different types of user's and the way I plan to model the profiles. |
How to add the ability to remove upvote or downvote on the second click? Posted: 15 Apr 2016 03:25 AM PDT Set my acts_as_votable, now the upvote and downvote buttons work properly but I want the user to remove his upvote on a second click like in facebook and twitter. Here's my controller and the index How can I achieve that? |
Posted: 15 Apr 2016 02:57 AM PDT I am trying to build a timetable setup to work in conjunction with one of my Models. Before I state my question, I will give some context into the problem. I have a Model called Appointments with the following columns: Now I can have multiple appointments in 1 day. For Example, let's say I have the following 2 Appointment objects: I would like to implement a date-picker form where you can select a date and it would render 24 rows(1 for each hour of the day) and fill in the rows with the times not available based on the appointments on that day. For example, if I select March 30, 2016 from the date-picker, I would like to render the 24 rows and have the rows for 11am-1pm and 2:00pm-3:00pm shaded out. The setup is like google calendars(how time slots are colored in) but with a day-to-day basis. I don't need to be able to edit these rows. I just need to view them and have them rendered with colored cells based on Appointment objects for that specific day. My issue is, I don't know where to begin to be able to design these 24 rows that interact with appointment objects. I was thinking that perhaps I build a helper method, however even that I am pretty lost. I would appreciate some guidance on how to approach this. |
Rolling back Model-changes from action Posted: 15 Apr 2016 02:16 AM PDT I have the action, in where I assign groups to the members that apply. Basically, I just get a list of emails, from the view in a form, and then I have the action to catch it: What I'm wondering is, that if I can rollback the changes that's been made already, if say the second member doesn't exist, or has a group already, how can I rollback these? What I've thought about already, was move the |
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