spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » RUBY ON RAILS » Page 5
Render object attributes on the same site with click
The short answer is no. When the link is clicked you will need to either render another page or handle the data returned by the controller with Javascript. The best option would be to set up an action that responds with JSON and parse what you get back on the front end. Even after your P.S. you will have to handle the response from the server with Javascript, unless you are okay with rendering a

Categories : Ruby On Rails

Neo4J gem associations and creating relationships
post.comments << comment3 creates an additional relationship between post and comment3. It doesn't do anything with the other relationships. The reason this looks weird to you is because post.comments doesn't retrieve anything from the database. Call class on it or any has_many association and you'll see that it's a Neo4j::ActiveNode::Query::QueryProxy object, which you can think of as an u

Categories : Ruby On Rails

Trouble with Heroku Deployment and Interpreting Heroku Log
2014-11-21T19:27:58.271705+00:00 app[web.1]: has_many :user, through :user_to_destinations doesn't look right - it should be has_many :user, through: :user_to_destinations at /app/app/models/destination.rb:3

Categories : Ruby On Rails

How to create a bootstrap paragraph 'help-block' for a input field in Rails 4
I would extract that into a helper. For example module ApplicationHelper def inline_help(help_text, object_name, method) content_tag :p, help_text, class: "help-inline", id: "#{object_name}_#{method}_inline" end end You can then use it within your form like this <%= form_for @model, url: {action: "create"} do |f| %> <%= f.label :name %> <%= f.text_field :name, placehold

Categories : Ruby On Rails

Rails/ActiveRecord query for quiz questions that have not been answered yet
I'm assuming the original queries are incorrect, since you are using QuizQuestionResponse ids as a parameter for QuizQuestion id. correct_question_ids = QuizQuestionResponse.where(correct: true, user_id: current_user.id, lesson_id: params[:quiz_response][:lesson_id]).pluck(:question_id) questions = QuizQuestion.where(lesson_id: params[:quiz_response][:lesson_id]).where.not(id: correct_question_i

Categories : Ruby On Rails

with_routing test helper doesn't work for integration tests
Ok, so I'm answering my own questions again. Problem is that with_routing doesn't work at all inside integration tests. Oversight or something, not sure. It only works for controller tests. So here's the work around: class ActionDispatch::IntegrationTest def with_routing(&block) yield ComfortableMexicanSofa::Application.routes ensure load File.expand_path('../config/cms_routes.rb'

Categories : Ruby On Rails

Base64 to video conversion
Use Base64.decode and write directly the results to a file. http://ruby-doc.org/stdlib-2.1.5/libdoc/base64/rdoc/Base64.html

Categories : Ruby On Rails

Is request.location in geocoder rails gem too slow for heroku?
If you set a timeout for the Geocoder gem you will need to set it to less than 30 seconds, which is how long you have for each request to Heroku. When the timeout is set to 40 seconds, the Geocoder request to the IP geolocation service will timeout after 40 second -- but at the point Heroku has already timed out the request and you see the H12 application error. Set the timeout to something less t

Categories : Ruby On Rails

Failure to set up mailer in Rails
I'd suggest using this in your routes file instead of resources: get 'account_activation', "account_activations#edit", :as => :edit_account_activation ...and deal with the secret token and email address params there. Right now the problem is that you don't have a controller action to match the route you're using in the account_activation.html.erb

Categories : Ruby On Rails

How to test Devise Async with Sidekiq?
As mentioned in the documentation, you can check the queue size as Sidekiq::Extensions::DelayedMailer.jobs.size

Categories : Ruby On Rails

PostgreSQL password authentication failed for user "postgres", not the same user as specified in my app config
I think your problem caused by using user in your database.yml instead of username. When you don't provide a username, it defaults to your current user. Are you still su - postgres when trying to launch your app? That would explain that why when it can't find a username, it falls back to 'postgres'. Being in postgres' environment might be causing your $MYAPP_DATABASE_PASSWORD environment variable

Categories : Ruby On Rails

Custom links on Paginate
You're not really paginating infos in this case. You're paginating created_on attribute for those records. So: make sure you have created_on on those records grab those records grouped by created_on. Raw sql, or a scope will do a job. (scope won't we returning proper objects though) When you have an array of created_on dates you'll need to create some sort of pagination control to display those

Categories : Ruby On Rails

Render Partial using Collection @Array and Object @Item
The short answer: you cannot control the instance variables in that way you're attempting. The best you can do is control the name of the local variable, like so: <%= render partial: "partial", collection: @item, as: :something_else %> And your partial will have access to an local variable called something_else, rather than item, as is normal. But you cannot cause the partial to create an

Categories : Ruby On Rails

Polymer icons within elements not rendering in Firefox or Safari (Rails app with Emcee gem)
If it works on chrome and does not work on Firefox, it seems like it might be an incompatibility issue. You might want to take a look at Polymers "Browser Compatibility" chart. And also, just in case, to see that you have the most recent version of Firefox. Also, what version of Polymer you are using? they have just gone from version 0.4.0 to 0.5.x, you might want to look into that. Version 0.4

Categories : Ruby On Rails

attr_encrypted and devise, Encrypt user data with users password
attr_encrypted provides a way to specify an instance method to provide the key. class Client < ActiveRecord::Base attr_encrypted :name, :age, key: :client_key def client_key # just assuming relation between Client and User self.user.encrypted_password end end Source: https://github.com/attr-encrypted/attr_encrypted#symbols-representing-instance-methods-as-keys

Categories : Ruby On Rails

Asset pipeline and storing stylesheets in the public folder
Even if you got Rails to serve the SCSS files, it would not process the SCSS files and generate the CSS that the browser wants. It must be in the asset pipeline to do that. You'll want to consider creating a separate asset manifest for your style guide.

Categories : Ruby On Rails

twilio test credentials do not work for sending sms‏ - throws exception "Resource not accessible with Test Account Credentials"
Because you're using TEST account, you MUST use one of the predefined to numbers like shown here: Twilio Doc If you use a real number, you'll get the error you see.

Categories : Ruby On Rails

How can I have 2 create methods?
Add this to route match 'contact', to: 'businesses#contact', via: [:post] or if you already have resources :businesses, you can add a collection route resources :businesses do collections do post :contact end end And add an action to businesses controller def contact ..

Categories : Ruby On Rails

how to capture output from rails runner "MyCloud::Deployment.checkuser" on a bash shell
Edit: You are confusing return values (objects returned to the same-language caller) with text output. You need to puts 20 to capture it as a string. You cannot capture return values from one language in another language without a foreign function interface or similar mechanism. A rare exception is the interface between *nix shells like Bash and Dash, where you can capture the return value from on

Categories : Ruby On Rails

How to call a field in my controller
If you're talking about when your form posts back to your action, you should be checking params. Either look in your logs or use binding.pry and look for the key and value you're expecting. It will probably be params[:comment][:honey].

Categories : Ruby On Rails

Rails sorting on a virtual attribute generated from a model method
It isn't possible to sort by a virtual attribute using ActiveRecord, however, we can use sort_by! on the result. http://www.ruby-doc.org/core-2.1.5/Array.html#method-i-sort_by-21 @boxes.sort_by! { |a,b| a.status <=> b.status } To automatically set the status, you could use after_find callback. #Box.rb attr_accessor :status after_find :generate_status def generate_status self.status

Categories : Ruby On Rails

has_many_through association not inserting values in params to join table instead inserting null
I need to know more about your data model but I can provide some general guidance here. class Cuisine < ActiveRecord::Base attr_accessible :cuisine_name, :id, :cuisine_id attr_accessor :tester, :cuisine_ids has_many :testers, :through => :ratings has_many :ratings First, adding ":id" to attr_accessible doesn't make sense. You don't need it as it would give people the ability to upda

Categories : Ruby On Rails

Run imported rake task with bundle
According the rake task import manual (provided by @Daiku). In the Rakefile, you can enumerate all the gems required in you project, and then try import all the rake task exported in those gems, if any, like this: Gem::Specification.all.each do |spec| Dir.glob('**/*.rake').each {|file| load file } end The try: $ rake -T

Categories : Ruby On Rails

Rails form doesn't create single params hash with input value
Remove the name: '...' option, because the helpers already set the name and it's not the one you are setting. In your case, rails will expect that the fields are named like contact[name] and contact[email] instead of the ones you are setting.

Categories : Ruby On Rails

Struggling with some more advanced authorizations using CanCan
First part: Assumptions: User belongs to Company Product belongs to Company Image belongs to Product Document belongs to Catalog These all permissions are affordable, by the third parameter of can method, e.g: can :manage, Image, :product => { :company => user.company_id } If company has many catalogs: can :manage, Document, :catalog => { :company => user.company_id } or

Categories : Ruby On Rails

God not running: The server is not available (or you do not have permissions to access it)
god load is use for loading or reloading configurations into an already running instance. In your case, your god server is not running. Here's the command to run god: god -c config/resque.god

Categories : Ruby On Rails

Unicorn crashing because of using wrong ruby version after deployment
A little late but could help others who are experiencing the same problem. I´m using rolling restart and what helped me was this comment which I have in my config/unicorn.rb file # If you roll off old code from your app servers (i.e. the way chef, capistrano, # basically anyone does it) you need to make sure Unicorn is not looking for # the Gemfile it was originally started with. I

Categories : Ruby On Rails

How can I dynamically set preserve_files option from a Paperclip file?
It seems you can't dynamically set the :preserve_files option, but there's another way to do what you want. Paperclip deletes attachments by first setting up a queue of paths to delete, and then deleting them when you save the object. An object can have multiple paths to delete if there are multiple styles of the same object (e.g. different sizes of an image file). If you call #destroy or #clear

Categories : Ruby On Rails

Ruby: how to remove items from array A if it's not in array B?
You can try something like a = [1,2,3] b = [1,4,5] pry(main)> a.delete_if {|a1| !b.include? a1} => [1] it checks each value in a is in b or not. If not it deletes the value from a and gives you a array finally. This is an example. You can use this accordingly

Categories : Ruby On Rails

How to prevent Ruby on Rails Active record from getting default model values from the database?
AFAIK: new only creates a model object which accepts a hash as a parameter in which keys are your table attributes. It does not query database at this point of time. Once you call the save method, it first calls valid? method to check if your object passes the validations you have defined. It is independent of database schema except for the uniqueness validation you have defined here. Uniqueness v

Categories : Ruby On Rails

Autoincrement month automatically rails
Assuming you have a Date stored in @month: @month += 1.month if condition If condition is evaluated to true then add one month. Otherwise leave @month as it is. Is that what you want?

Categories : Ruby On Rails

Modify dependency gem
To make some changes in the gem you have just to create a brunch in the gem, and then point the branch inside the Gemfile of the Rails project to the gem branch, for example: gem 'your-gem', :git => 'https://github.com/you/your-gem.git', :branch => 'new-project-branch' More docs on definition you can find on bundler doc page. NOTE: Of course you can use :path key instead of git or github

Categories : Ruby On Rails

Rails, separate search function within rails form
Add a hidden array field in the form called products. outside the form handle products search,selection and update of that hidden field via Ajax call. Check this link, Its a similar but simpler example cause he just want to add addresses dynamically while you still have the products searching handled via Ajax first. Please note that the only part you need from his solution is how he updates the f

Categories : Ruby On Rails

Error Installing RMagick for Ruby on Rails on Windows
Please follow steps in the following link your link seems to be missing dll linking http://www.redmine.org/projects/redmine/wiki/HowTo_install_rmagick_gem_on_Windows

Categories : Ruby On Rails

Rails model namespace and named_helpers
Rails' using model class: Operations::Expense to create the routes for new and edit methods. As it try to use the namespace and convert it into route something like: operations_expenses_(path/url). Since, you have scope module: 'operations', it creates expenses_(path/url) methods instead. Try changing your routes to this: namespace :operations, path: '/' do resources :expenses end This wil

Categories : Ruby On Rails

cancancan + devise: handling timeoutable exception
When the session times out, the value of flash[:alert] is set to :timeout, which by default is defined in config/locales/devise.en.yml. So instead of reading the message from exception, try reading from flash[:alert] and make your app react accordingly. For example, this is the code I use in my apps: rescue_from CanCan::AccessDenied do |exception| if user_signed_in? # Blank page with an er

Categories : Ruby On Rails

expect object to receive method in a controller using Rspec
@cart_product_design is only set by the inherited update! method, so it should be nil when you call some_method on it in the first statement of your controller method. Is your method really called some_method? To do what you want to do, see the README for the Inherited Resources gem and look for this example: class ProjectsController < InheritedResources::Base def update @project = Proj

Categories : Ruby On Rails

getting multiple radio buttons in rails
What you are looking for is fields_for. Take a precise look at docs and you'll know, how to iterate over each question

Categories : Ruby On Rails

Rails Has Many Through Relationship - Difference Between New-Save and Create
The Fix You need to set your inverse relationships on your models to guarantee the build and new on associations will work consistently to setup the relationships, foreign keys, and intermediate associations: class Project < ActiveRecord::Base has_many :twitter_memberships, inverse_of: :project has_many :twitter_accounts, through: :twitter_memberships end class TwitterMembership < Ac

Categories : Ruby On Rails


Recently Add
Why isn't the confirm box working?
Polymorphic models (not associations!) in Rails
Link_to :Action won't call Controller Method -- Rails 4
Missing template when rendering a collection using local variables
rails simple_form using virtual attributes
uninitialized constant ActiveSupport::TestCase
Rails 4, Paperclip, S3 wrong url path
Neo4j gem - Updating relationship properties method
Error trying to deploy Rails app to Heroku
Modyfying before_action
CarrierWave TypeError (can't dump File) on Heroku
CanCan Ability in Rails - Giving partial manage
Uploading two images using s3 and paperclip on rails app
How to pass hash values of ActiveRecord::Base class
Ruby on rails. Heroku compile assets timeout when i add unicorn gem
Rails Template is Missing Error
Time.now.to_i different on heroku and locally
Simple rails app on Puma throws segfault, cannot handle concurrency
Setting Up Rails to Receive HTTP POST Request
Rails: Is it safe to use params[:bar] in link_to helper?
How to add aggregated columns from SQL SELECT to AR object in Rails
Circular Dependency Error autoloading constant
Groups and Users has many oder has many through?
Rails format specifier differences
Capistrano can not create symlinks: file exist
Admin can't delete users. Ruby on Rails 3 - Michael Hartl
Don't show user name who create post
Using Wicked with Devise (2 step signup process)
RubyOnRails Rake test failures
Rails session start event handler
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.