Questions tagged [ruby-on-rails-plugins]

99264 questions
1

votes
1

answer
2.8k

Views

Rails 4 Strong Params has_many with JSON

I'm attempting to pass json up on the client side and have rails take care of handling the object creation. Here are my models: class Order < ActiveRecord::Base has_many :order_items, :autosave => true belongs_to :menu_session end class OrderItem < ActiveRecord::Base belongs_to :order has_one :menu_...
TomJ
0

votes
1

answer
21

Views

Rails downloads empty file when doing a POST request

I have a POST method that adds a like to a model post def like post = Post.find(params[:id]) post.likes += 1 post.save end I'm a using a link_to to call it. But whenever I click, an empty file downloads. Click here to see the image
Davis Roberto
1

votes
1

answer
247

Views

Using .select, .uniq and .order in PostgreSQL

I have a one-to-many relationship between the models Organizer and Event. I want to get the five organizers that most recently has updated an event. Event.order('updated_at asc'). where(organizer_id: [1,2,3,4,5,6,7,8,9]). select(:organizer_id).uniq.limit(5) The above code works good in SQLite3 but t...
Fellow Stranger
1

votes
1

answer
1.3k

Views

AbstractController::ActionNotFound error, even though routes.rb is configured

I have a UserController with these methods: class UserController < ApplicationController # snip def test_add_realtime_code end def add_realtime_code if request.post? # snip end end end In my routes.rb, I have this: match '/user/add_realtime_code', :controller => 'user', :action => 'add_realtime_code...
Kevin
1

votes
6

answer
3.6k

Views

Disabled radio button in simple_form with an array

What is the best way to place two radio button inside a simple_form, where one button is by default disabled and another is selected! f.input_field :listing_type, as: :radio_buttons, collection: [ "lease", "sale"], :item_wrapper_class => 'inline' this is giving me two buttons where both are enabled...
geekdeepak
1

votes
2

answer
881

Views

How to optimize/cache Rails query

I've Rails application where query takes way too long time. It uses postgresql DB and query consists of one table with thousands of records. statistics_controller.rb all_data = Usagedata.select([:start_time, :end_time, :node_count, :processors, :id, :wall_duration, :local_user_id]) .where(Usagedata...
Raccoon
1

votes
1

answer
1.6k

Views

Google Calendar API V3 - Insert Calendar

I am playing around with Google calendar API and came across this: Google Calendar V3 Insert The Ruby code doesn't seem to be Ruby code so I ported information from the calendar_list and calendar.get to this. I'm not sure why the parameter summary is not being picked up as a title. def create...
ebbflowgo
1

votes
2

answer
962

Views

Freezing Rails gem versions

I am trying to freeze my Rails gem version as, day by day, some or the other gem version gets updated and sometimes I need to update the code. I tried rake rails:freeze:gems but this gave me error: rake aborted! Don't know how to build task 'rails:freeze:gems'
Sagar.Patil
1

votes
4

answer
1.1k

Views

Cannot register user Unpermitted parameters error with devise and devise_invitable

I am on Rails3.2 devise_invitable (1.1.8), devise (3.1.1) WITHOUT strong parameter, when I try to register a user I get following log. I am using this route to custom the devise invitation controller: devise_for :users, path_names: {sign_in: "login", sign_out: "logout"}, :controllers => { :invita...
user1883793
1

votes
2

answer
1.8k

Views

How can I return a 404 for a specific URL with Rack middleware

A site I manage is getting constant requests for a javascript file that no longer exists, from an older version of the site. These requests take up a lot of resources because they get routed through Rails every time to return a 404. I am thinking it would be much better to have Rack handle that spec...
koosa
1

votes
1

answer
975

Views

How to hide Edit and Delete actions from Show view in ActiveAdmin?

just added Active Admin to my project. I want hide the Edit & Delete action form the Show page, and Edit & Delete action should present in Index page. Is there a better way to do this? Thanks in advance.
Sampat Badhe
1

votes
2

answer
584

Views

Using scope in Rails model for gathering “private” posts

I have a table of user Posts, some of which are private, denoted by a boolean column (privacy) in the table (true being private). In my livefeed view (posts/index.html.erb), I want to show only the non-private posts for ALL users. Can I do this via my scope? Note: In my usersfeed view I am showing p...
Jet59black
1

votes
1

answer
2k

Views

eCommerce solution for ruby on rails with multi-store support [closed]

As i know in rails there is limited support for eCommerce solution(few options): Spree Ror-e Substruct Piggybak I didn't use any of this, but wanted to ask that anyone have experience between these solutions, pros&cons. I found similar question: https://stackoverflow.com/questions/9382268/clean-e-co...
Srle
1

votes
2

answer
2.9k

Views

Cannot upload file

I have problems to upload a file: Here is my html: 'display:inline; margin-top:-10px' %> 'btn btn-sm btn-info' %> First i tried to simply upload it and to handle it in my controller like this: def import widgets = DBF::Table.new(params[:file], nil, 'cp1252') w = widgets.find(6) p = Patient.new p.vor...
John Smith
1

votes
1

answer
127

Views

Ruby app pushed to Heroku displaying issues

I am running a Ruby on Rails application with a PostgreSQL database. This is the first time I pushed an app with its database to heroku, so I had no idea what to expect. What I got was my main page working as intended; but the Users page (page created by Rails scaffold command wich should display da...
Nuno Roma
1

votes
2

answer
187

Views

Can I create a new entry in a Rails db by posting XML data in lieu of form data?

I'm playing with a very simple contacts Rails app. I have a /contacts route that I can POST to add entries in the contacts table (using scaffold). I want instead to send XML data in the POST (rather than FORM data) using XMLHttp Request. The request works, but the params object in Rails doesn't show...
Fred Finkle
1

votes
3

answer
370

Views

Rails: Joining by one table OR another table

I'm looking for a more efficient way to write an ActiveRecord query. I want to get all instances of a model that either join one table or another table. Both is easy, but either is difficult. Right now, I have the following two queries: across_clues = Clue.joins(:across_cells) down_clues = Clue.join...
Dylan
1

votes
1

answer
1.4k

Views

mailboxer gem - find message sender

I am having the hardest time with the mailboxes gem. I have gotten it working in that I can send and receive messages, but for the life of me I cannot figure out how to display them. i want to display the inbox in table organized like this: message sender | message subject | message sent date I ha...
Philip7899
1

votes
1

answer
643

Views

Validation message helper or retrieving validation error

P.S: I've been working with Ruby for less than 48 hours, so expect me to be dumb! I have set up validation on a model which all works fine. However I want to modify the message retuned by the uniqueness constraint. The message needs to be returned by a method which does some additional processing. S...
Lee
1

votes
3

answer
200

Views

Ruby using step method to return large numbers with delimiter?

(2500..75000).step(2500).to_a #=> [2500, 5000, 7500, 10000, 12500, 15000, 17500, 20000, 22500, 25000, 27500, 30000, 32500, 35000, 37500, 40000, 42500, 45000, 47500, 50000, 52500, 55000, 57500, 60000, 62500, 65000, 67500, 70000, 72500, 75000] How do I get the output to be: [ '2,500', '5,000', '7,500...
fabbb
1

votes
2

answer
689

Views

Rails Table - Dynamic Conditional Font Formatting

I am trying to set the font color of dynamic values as follows: if incident.state_id = 1, then red font, if incident.state_id = 2, then yellow font, if incident.state_id = 3, then red font. incident.state_id = 1 : state.name = "Pending Investigation" incident.state_id = 2 : state.name = "Investigat...
Katie M
1

votes
1

answer
271

Views

syntax error, unexpected keyword_or scope

I'm running Feed.history but It's raised the error above in title because of my scope line in Feed model: scope :history, -> { or({:end.ne => nil}, {:end.lt => Time.current}) } what and why?!!
Zakwan
1

votes
2

answer
67

Views

What happened while using a hash as the parameter when initializing a instance in Ruby?

I defined a class for User, which takes a hash as parameter, class User attr_accessor :name, :email def initialize(attributes = {}) @name = attributes[:name] @email = attributes[:email] end def formatted_email "#{@name} " end end While initializing in console using parenthesis and empty space synt...
eggplantelf
0

votes
0

answer
6

Views

Ruby on Rails, Can I get the current count of connections in Mongoid pool?

I have set min_pool_size to 100 in mongoid.yml but in mongo when running db.serverStatus().connections i only get 30. Is there a way to check how many connections I have in pool?
user793789
1

votes
2

answer
110

Views

How to separate (new,create,delete) actions and show action in Rails for a blog?

Im trying to build a blog and having some issues. The blog have a separate dashboard with its own layout /dashboard. Imagine that I have a model named post. In the blog, the blog post URLs will be like /post/hello-world. Normally its easy to add, edit and delete these posts. I just have to add resou...
THpubs
1

votes
3

answer
1.1k

Views

How to remove current_user from index of all users?

In otherwords, in my app I have an index that displays the number of total users I'd like to exclude the current_user from this list.. I've used the following code to prevent the user.name and user.profile_photo from showing successfully: However, it still says Showing 2 users when it only shows th...
user3399101
1

votes
2

answer
2.6k

Views

boostrap in a rails application, 404 (Not Found)

I've tried to integrate bootstrap following this procedure found on stackoverflow (my rails version is the 3.2.17, this is a difference), so without a gem but just including the bootstrap files in the relevant project directories. Then i've created an HTML page and i put it in the project public di...
AgostinoX
1

votes
1

answer
2k

Views

How to convert time from UTC to PST in rails

I Ruby on rails application, i am getting time in UTC from database (i.e. in active record object). I want to convert the time to PST before displaying to UI. I tried doing this dataFromDB = DataTable.find_by_sql("select time from datatables"); dataFromDB[0].time = dataFromDB[0].time.in_time_zone("P...
Ajay
1

votes
1

answer
963

Views

Ruby does not detect after installing using RVM

My configurations Ubuntu 14.04 amd64 I followed this tutorial to install Ruby Successfully installed ruby. Closed the Terminal. Checking ruby -v shows The program 'ruby' can be found in the following packages: * ruby * ruby1.8 Try: sudo apt-get install 4.Runs the command [[ -s "$HOME/.rvm/...
deadbug
1

votes
1

answer
379

Views

dots in rails URL

I'm trying to add a show page to my devise users but can't seem to get the id value passed properly, how do I create a link to the show page? For some reason rails is doing this to URL /show.1 users controller: def show @user = User.find(params[:id]) end user/show.html.erb link to user profile also...
franklinexpress
1

votes
1

answer
154

Views

Ruby on Rails - How to set cron on local

Suppose, we have a rake task, to be run like, rake RAILS_ENV=development parse_and_insert_feed_in_db We can set this task to be execute repeatedly on server using crontab's. 1 0 * * * rake RAILS_ENV=development parse_and_insert_feed_in_db > /some/dir/file.log How can we set a rake task to be execu...
Akshay Mohite
1

votes
2

answer
2.1k

Views

Ruby on Rails view not pulling in application.html.erb layout

I'm having some issues with a set of views in my rails app. I created ran scaffold to create a posts model, controller and views. They work just fine on their own, but they refuse to pull in the application.html.erb layout. This is the posts controller: class PostsController < ApplicationController...
CoreyT
1

votes
1

answer
1.1k

Views

How to create a Elasticsearch test environment to run my capybara tests (rails app)

My scenario I have a rails app that uses elasticsearch to index some data. For my unit and integrations automated tests I just mock elasticsearch using FakeWeb but now I want to write some acceptance tests and I would like to use elasticsearch without mocking it. My question How can I run 2 clusters...
1

votes
3

answer
616

Views

Log Data Analytics : Choice of Database [closed]

I am getting Log Data from various web applications in the following format: Session Timestamp Event Parameters 1 1 Started Session 1 2 Logged In Username:"user1" 2 3 Started Session 1 3...
Peeyush
1

votes
4

answer
1.1k

Views

Validate uniqueness of globalized field

I have a model with translated fields using the globalize gem and globalize-accessors gem for providing localized attributes such as name_en, name_zh_hk for a localized name field. for example: class Person < ActiveRecord::Base translates :name globalize_accessors: locales: [:en, :"zh-HK"], attribut...
PeterWong
1

votes
1

answer
118

Views

Rails model scoped uniqueness validation unexpectedly skipped in high CPU load

I realized that Rails scoped validation sometimes skipped unexpectedly which results in duplicated record. As a notice, my server is doing some high CPU tasks which regularly fills 80-100% of 6 CPU cores. Is my validation setting incorrect, or does Rails has a possibility to insert duplicated record...
tomodian
1

votes
1

answer
424

Views

Is there a way to evaluate erb code outside rails view template

Wondering if there is a way to evaluate a snippet of erb code to see the html that it would generate when included in the rails view template without running rails? for eg. the below erb code snippet generates the following html Article ID Is there a quick way to check the above and other html code...
user3206440
1

votes
2

answer
855

Views

Ruby how can i get date of Monday after a given date

Given A Day i-e Monday and a Date e.g: Sat, 09 Aug 2014 how can i get the date of Monday coming immediately after given Date Update: def get_date_after(date, day) return date if date.wday == day.to_date.wday days_difference = (date - day.to_date).to_i result = day.to_date + days_difference + (day.to...
Saqib
1

votes
2

answer
89

Views

Nested Resource Creation in Parent Form

I have a class called Quote which has_many :line_items, as: :line_itemable (line_items are polymorphic). A quote must have at least one line_item upon creation, so in my Quote creation form I have a section dedicated to adding line items. My routes look like this: resources :quotes, shallow: true do...
davidicus
1

votes
3

answer
366

Views

CI tool with code metrics for ruby on rails application

I need to integrate a CI(continues integration)+CD(continuous deployment) tool for my ruby on rails application. It would be great if it has the following features. Code metric tool like (metric_fu) Gitlab,Gitlub for repository managements. Following are the list of CI tool I'm consider. https://tra...

View additional questions