Search Results

Search found 13929 results on 558 pages for 'ruby on rails plugins'.

Page 32/558 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • A very basic issue with routes in ruby

    - by Haris
    I am new to ruby and while creating a sample application found out an issue that whenever I go to http://127.0.0.1:3000/people/index by default show action is executed and index is taken as a parameter. This is server log: Started GET "/people/index" for 127.0.0.1 at 2010-12-23 18:43:01 +0500 Processing by PeopleController#show as HTML Parameters: {"id"=>"index"} I have this in my route file: root :to => "people#index" resources> :people match ':controller(/:action(/:id(.:format)))' What is going on here and how can I fix the issue?

    Read the article

  • Some questions about setting up Amazon S3 with Ruby on Rails

    - by ben
    I'm trying to setup Amazon S3 hosting with my Ruby on Rails 3 app, which is hosted on Heroku. After reading these instructions in the Heroku docs, I'm trying to use the aws-s3 gem. The instructions say to put the S3 account details in config/amazon_s3.yml, but the aws-s3 Github page says you create a connection like this: AWS::S3::Base.establish_connection!( :access_key_id => 'abc', :secret_access_key => '123' ) Why is the connection created by providing the details if they're already provided in the config file? Is that not the correct way to establish a connection? Do I have to establish a connection for each user everytime an upload is about to occur, or is a connection established for the application as a whole? Thanks for reading.

    Read the article

  • Ruby ways to authenticate using headers?

    - by webdestroya
    I am designing an API system in Ruby-on-Rails, and I want to be able to log queries and authenticate users. However, I do not have a traditional login system, I want to use an APIkey and a signature that users can submit in the HTTP headers in the request. (Similar to how Amazon's services work) Instead of requesting /users/12345/photos/create I want to be able to request /photos/create and submit a header that says X-APIKey: 12345 and then validate the request with a signature. Are there any gems that can be adapted to do that? Or better yet, any gems that do this without adaptation? Or do you feel that it would be wiser to just have them send the API key in each request using the POST/GET vars?

    Read the article

  • Ruby efficient way of building an array from an array of arrays

    - by randombits
    I have an array of ActiveRecord objects, each one which has its own respective errors array. I want to flatten it all out and get only the unique values into one array. So the top level array might look like: foo0 = Foo.new foo1 = Foo.new foo2 = Foo.new foo3 = Foo.new arr = [foo0, foo1, foo2, foo3] Each one of those objects could potentially have an array of errors, and I'd like to get just the unique message out of them and put them in another array, say called error_arr. How would you do it the "Ruby" way?

    Read the article

  • ruby tests - error messages don't include line numbers or file name

    - by joshs
    Hi all, How do I get line numbers to be reported with my errors when testing. Here is what I get back on a typical error: josh@josh-laptop:~/d/test$ ruby unit/line_test.rb -n test_update Loaded suite unit/line_test Started E Finished in 0.066663 seconds. 1) Error: test_update(LineTest): NameError: undefined local variable or method `sdf' for #<LineTest:0xb6e61304> 1 tests, 0 assertions, 0 failures, 1 errors It is tough to debug without a line number and filename. From the code samples I've seen, people generally get back a more verbose error reports. How do I enable this? Thanks!

    Read the article

  • ruby / rails boolean method naming conventions

    - by Dennis
    I have a short question on ruby / rails method naming conventions or good practice. Consider the following methods: # some methods performing some sort of 'action' def action; end def action!; end # some methods checking if performing 'action' is permitted def action?; end def can_action?; end def action_allowed?; end So I wonder, which of the three ampersand-methods would be the "best" way to ask for permissions. I would go with the first one somehow, but in some cases I think this might be confused with meaning has_performed_action?. So the second approach might make that clearer but is also a bit more verbose. The third one is actually just for completeness. I don't really like that one. So are there any commonly agreed-on good practices for that?

    Read the article

  • locale based sorting function in ruby

    - by railscoder
    For my application(Ruby on Rails) i have country select box for the signup page. These countries are localized into different language. But i couldnt find a way to sort them, based on the language in which its localized. At present i have sorted it out based on english only. Is there a way to sort the country names based on the locale? i.e the order of the countries should change(ascending order) according to the language its localised. Thanks..

    Read the article

  • XML testing in Rails - Fixed attributes order in Builder::XmlMarkup in ruby -

    - by Daniel Cukier
    I have the following test in my Rails Application: it "should validate xml" do builder = Builder::XmlMarkup.new builder.server(:name => "myServer", :ip => "192.168.1.1").should == "<server name=\"myServer\" ip=\"192.168.1.1\"/>" end The problem is that this test passes sometimes, because the order of the xml tag attributes is unpredictable. Is there a way to force this order? Is there any other easy way to build xml? This example is simplified, I have a big XML. My problem is that I want to do an integration test, which compares a WebService call with a fixed XML file. Otherwise, I would have to parse the xml and verify element by element in the XML.

    Read the article

  • Escape doube and single backslashes in a string in Ruby

    - by Nick Gorbikoff
    Hello. I'm trying to access a network path in my ruby script on a windows platform in a format like this. \\servername\some windows share\folder 1\folder2\ Now If I try to use this as a path, it won't work. Single backslashes are not properly escaped for this script. path = "\\servername\some windows share\folder 1\folder2\" d = Dir.new(path) I tried everything I could think of to properly escape slashes in the path. However I can't escape that single backslash - because of it's special meaning. I tried single quotes, double quotes, escaping backslash itself, using alternate quotes such as %Q{} or %q{}, using ascii to char conversion. Nothing works in a sense that I'm not doing it right. :-) Right now the temp solution is to Map a network drive N:\ pointing to that path and access it that way, but that not a solution. Does anyone have any idea how to properly escape single backslashes? Thank you

    Read the article

  • ruby on rails: audio/mp3 content header download

    - by bandhunt
    How do you set the headers for downloads in ruby/rails? In php I'd set the header for an mp3 download like this: header("Content-Transfer-Encoding: binary"); header("Content-type: audio/mp3"); header("Content-Disposition: attachment; filename=\"$songname.mp3\""); header("Content-Length: " . $size); @readfile("http://example.com/12345.mp3"); Seems like there should be an easy should an easy solution. I did find this: response.headers['Content-type'] = 'Content-type: audio/mp3' But I'm not sure how/where the readfile would come into play and other headers. Thanks!

    Read the article

  • Breakdown of this Ruby code?

    - by randombits
    Would anyone be kind enough to dissect the merge! method? Its usage of conditions and variable assignment looks rather terse, and I'm having a difficult time following it. Would love to hear a Ruby-savvy developer break this apart. module ActiveRecord class Errors def merge!(errors, options={}) fields_to_merge = if only=options[:only] only elsif except=options[:except] except = [except] unless except.is_a?(Array) except.map!(&:to_sym) errors.entries.map(&:first).select do |field| !except.include?(field.to_sym) end else errors.entries.map(&:first) end fields_to_merge = [fields_to_merge] unless fields_to_merge.is_a?(Array) fields_to_merge.map!(&:to_sym) errors.entries.each do |field, msg| add field, msg if fields_to_merge.include?(field.to_sym) end end end end

    Read the article

  • Installing Ruby on Rails in Fresh Ubuntu 10.10 System

    - by Benedict Aluan
    There are a lot of tutorials on how to install Ruby on Rails in Ubuntu 10.10. But even following the steps, there are still errors and dependencies that will encountered in order to successfully install RoR. The system varies on the developer's setup. To make it uniform, installation must be on a fresh Ubuntu 10.10 system. Is there a step-by-step guide on how to install RoR on a Fresh Ubuntu 10.10 machine? Like the first thing I need to do after starting the terminal.

    Read the article

  • ruby on rails regular expression to remove html tags and its content from text

    - by salilgaikwad
    Hi All, I want regular expression in ruby on rails which remove all the html tags and its content from the given text. For example if my text is :-INPUT :- <span id="span_is"><br><br><u><i>Hi</i></u></span> then it should display only OUTPUT should be as follows:- Hi in short i want regular expression or a function which remove < and whatever the content between <. Thanks & Regards, Salil Gaikwad

    Read the article

  • What is Ruby's double-colon (::) all about?

    - by Meltemi
    I'd probably be able to answer this for myself if "::" wasn't so hard to Google. Didn't see anything on SO so thought I'd try my luck. What is this double-colon :: all about? I see it everywhere in Rails: class User < ActiveRecord::Base or… ActionController::Routing::Routes.draw do |map| I found a definition from this guy: The :: is a unary operator that allows: constants, instance methods and class methods defined within a class or module, to be accessed from anywhere outside the class or module. but that just leads to more questions. What good is scope (private, protected) if you can just use :: to expose anything?

    Read the article

  • Regular expression in Ruby

    - by Sainath Mallidi
    Hi, Could anybody help me make a proper regular expression from a bunch of text in Ruby. I tried a lot but I don't know how to handle variable length titles. The string will be of format <sometext>title:"<actual_title>"<sometext>. I want to extract actual_title from this string. I tried /title:"."/ but it doesnt find any matches as it expects a closing quotation after one variable from opening quotation. I couldn't figure how to make it check for variable length of string. Any help is appreciated. Thanks.

    Read the article

  • Implement a calender with Ruby and Javascript in Rails

    - by samuel02
    I'm trying to implement a calendar with Ruby and Javascript in Rails. I'm using a calendar helper that creates a calendar with given year and month and events as parameters (<%= calendar(:year => 2012, :month => 4, :events => @events %>). I also have three buttons next, today and previous with which the user should be able to navigate the calendar with. I am also going to implement some js that makes it possible to select dates in the calendar. So what I would like to do is to insert the calendar in the DOM with javascript in order to generate a new calendar when the user clicks one of the buttons. That way I will be able to control the behavior of the buttons and add the select functionality. The problem is that I can't just insert my erb code in a javascript plus I'm not even sure it's the right way to go? Any suggestions are appreciated!

    Read the article

  • Ruby/RoR: calling original method via super()?

    - by fearless_fool
    In a RoR app, I want to specialize ActiveRecord's update_attributes() method in one of my models, extracting some of the attributes for special handling and passing the rest of them to the original update_attributes() method. The details: class Premise < ActiveRecord::Base ... def update_attributes(attrs) attrs.each_pair do |key, val| unless has_attribute?(key) do_special_processing(key, val) attrs.delete(key) end end # use original update_attributes() to process non-special pairs super.update_attributes(attrs) end ... end The call to super.update_attributes(attr) raises an error: undefined method `update_attributes' for true:TrueClass ... which makes me suspect I really don't understand the super keyword in Ruby. What am I missing? Specifically, how do I call the original update_attributes() method?

    Read the article

  • Having trouble routing a page in ruby

    - by rockyroadster555
    I currently have a users model and controller, whenever a user is created it makes there profile url at example.com/users/userid. I also have a users/new page and a users/index page. The issue is that when I try to create a users/selected users page rails thinks its a user id and gives me this error. "Couldn't find User with id=selectedusers." I've previously been able to fix this by directly calling the pages in the controller e.g index, or new but I'm not sure how to handle a page that doesent have a function in the controller. Thank you

    Read the article

  • Overriding Ruby's spaceship operator <=>

    - by ericsteen1
    I am trying to override Ruby's <= (spaceship) operator to sort apples and oranges so that apples come first sorted by weight, and oranges second, sorted by sweetness. Like so: module Fruity attr_accessor :weight, :sweetness def <=>(other) # use Array#<=> to compare the attributes [self.weight, self.sweetness] <=> [other.weight, other.sweetness] end include Comparable end class Apple include Fruity def initialize(w) self.weight = w end end class Orange include Fruity def initialize(s) self.sweetness = s end end fruits = [Apple.new(2),Orange.new(4),Apple.new(6),Orange.new(9),Apple.new(1),Orange.new(22)] p fruits #should work? p fruits.sort But this does not work, can someone tell what I am doing wrong here, or a better way to do this?

    Read the article

  • Ruby and Rails Async

    - by Edijs Petersons
    I need to perform long-running operation in ruby/rails asynchronously. Googling around one of the options I find is Sidekiq. class WeeklyReportWorker include Sidekiq::Worker def perform(user, product, year = Time.now.year, week = Date.today.cweek) report = WeeklyReport.build(user, product, year, week) report.save end end # call WeeklyReportWorker.perform_async('user', 'product') Everything works great! But there is a problem. If I keep calling this async method every few seconds, but the actual time heavy operation performs is one minute things won't work. Let me put it in example. 5.times { WeeklyReportWorker.perform_async('user', 'product') } Now my heavy operation will be performed 5 times. Optimally it should have performed only once or twice depending on whether execution of first operaton started before 5th async call was made. Do you have tips how to solve it?

    Read the article

  • Can you recommend wiki, forum, blog & cms plugins for an existing Rails app or should I go the route

    - by Nick Gorbikoff
    Hello. I have an existing Rails internal app, that handles inventory, invoicing, order taking, labeling, data imports/exports, etc, etc. Now I need to add blog, cms, forum and wiki functionality to it. It seems silly to try to roll out my own solutions when there are already some out there. So I was wondering if people could recommend based on their experience: Are there good plugins out there? (Which ones you had experience with?) Would you rather recommend to go the route of engines, and integrate RadiantCMS or similar apps? (please provide recommendations based on your integration experience) Or would you just bite the bullet and roll out your own? Thank you. P.S.: Right now the app is Rails 2.3, but it will get upgraded to Rail 3 in a year, when most gems/plugins that it depends on will be Rails 3 compatible.

    Read the article

  • Ruby Hash.merge with specified keys only

    - by ba
    I'm pretty sure I saw on a Rails related site something along the lines of: def my_function(*opts) opts.require_keys(:first, :second, :third) end And if one of the keys in require_keys weren't specified, or if there were keys that weren't specified, an exception was raised. I've been looking through ActiveSupport and I guess I might be looking for something like the inverse of except. I like to try and use as much of the framework as possible compared to writing my own code, that's the reason I'm asking when I know how to make the same functionality on my own. :) At the moment I'm doing it through the normal merge routine and making sure that I have what I need with some IFs.

    Read the article

  • Active Scaffold + Ruby 2.3.5 not working

    - by rodrigoaronas
    Hello, I have an application with Rails 2.3.5. And Im trying to use AS latest version, I have used it previously but cant make it work here. I have my ingredient_categories Controller, where i put class Administration::IngredientCategoriesController < ApplicationController layout "default" active_scaffold :ingredient_categories end I have this set up on routes to be :active_scaffold=true I have a model also called ingredient_category, and in the views folder (inside administration/ingredient_categories, and /ingredient_categories) i have nothing as it is usual. And Im getting over and over again: Template is missing Missing template ingredient_categories/list.html in view path themes/aqueouslight:app/views I had an error before asking me for a list.erb, which I created and put <%= render :active_scaffold = 'ingredient_categories', :label = 'Categorias' % And now this error of the list.thml... Cant make it work! dont know whhy really... whould be SO simple and its burning my head now.. Thanks!

    Read the article

  • How to troubleshoot a Highcharts script that's not rendering data when date is added and hanging the JS engine with large datasets?

    - by ylluminate
    I have a Highchart JS graph that I'm building in Rails (although I don't think Ruby has real bearing on this problem unless it's the Date output format) to which I'm adding the timestamp of each datapoint. Presently the array of floats is rendering fine without timestamps, however when I add the timestamp to the series it fails to rend. What's worse is that when the series has hundreds of entries all sorts of problems arise, not the least of which is the browser entirely hanging and requiring a force quit / kill. I'm using the following to build the array of arrays data series: series1 = readings.map{|row| [(row.date.to_i * 1000), (row.data1.to_f if BigDecimal(row.data1) != BigDecimal("-1000.0"))] } This yields a result like this: series: [{"name":"Data 1","data":[[1326262980000,1.79e-09],[1326262920000,1.29e-09],[1326262860000,1.22e-09],[1326262800000,1.42e-09],[1326262740000,1.29e-09],[1326262680000,1.34e-09],[1326262620000,1.31e-09],[1326262560000,1.51e-09],[1326262500000,1.24e-09],[1326262440000,1.7e-09],[1326262380000,1.24e-09],[1326262320000,1.29e-09],[1326262260000,1.53e-09],[1326262200000,1.23e-09],[1326262140000,1.21e-09]],"color":"blue"}] Yet nothing appears on the graph as noted. Notwithstanding, when I compare the data series in one of their very similar examples here: http://www.highcharts.com/demo/spline-irregular-time It appears that really the data series are formatted identically (except in mine I use the timestamp vs date method). This leads me to think I've got a problem with the timestamp output, but I'm just not able to figure out where / how as I'm converting the date output to an integer multipled by 1000 to convert it to milliseconds as per explained in a similar Railscasts tutorial. I would very much appreciate it if someone could point me in the right direction here as to what I may be doing wrong. What could cause no data to appear on the graph in smaller sized sets (<100 points) and when into the hundreds causes an apparent hang in the javascript engine in this case? Perhaps ultimately the key lies here as this is the entire js that's being generated and not rendering: jQuery(function() { // 1. Define JSON options var options = { chart: {"defaultSeriesType":"spline","renderTo":"chart_name"}, title: {"text":"Title"}, legend: {"layout":"vertical","style":{}}, xAxis: {"title":{"text":"UTC Time"},"type":"datetime"}, yAxis: [{"title":{"text":"Left Title","margin":10}},{"title":{"text":"Right Groups Title"},"opposite":true}], tooltip: {"enabled":true}, credits: {"enabled":false}, plotOptions: {"areaspline":{}}, series: [{"name":"Data 1","data":[[1326262980000,1.79e-08],[1326262920000,1.69e-08],[1326262860000,1.62e-08],[1326262800000,1.42e-08],[1326262740000,1.29e-08],[1326262680000,1.34e-08],[1326262620000,1.31e-08],[1326262560000,1.51e-08],[1326262500000,1.64e-08],[1326262440000,1.7e-08],[1326262380000,1.64e-08],[1326262320000,1.69e-08],[1326262260000,1.53e-08],[1326262200000,1.23e-08],[1326262140000,1.21e-08]],"color":"blue"},{"name":"Data 2","data":[[1326262980000,9.79e-09],[1326262920000,9.78e-09],[1326262860000,9.8e-09],[1326262800000,9.82e-09],[1326262740000,9.88e-09],[1326262680000,9.89e-09],[1326262620000,1.3e-06],[1326262560000,1.32e-06],[1326262500000,1.33e-06],[1326262440000,1.33e-06],[1326262380000,1.34e-06],[1326262320000,1.33e-06],[1326262260000,1.32e-06],[1326262200000,1.32e-06],[1326262140000,1.32e-06]],"color":"red"}], subtitle: {} }; // 2. Add callbacks (non-JSON compliant) // 3. Build the chart var chart = new Highcharts.StockChart(options); });

    Read the article

  • No such file to load bundler error for Rails 3

    - by kgpdeveloper
    I have a Rails 3 app ready for staging. I haven't got a VPS host set up yet. As I was planning to have everything on shared host for the first few months. Problem: cd myapp bundle check result: The Gemfile's dependencies are satisfied Passenger error: Error message: no such file to load -- bundler Exception class: LoadError Frustrating thing about shared hosts is that I have to add these lines on config.ru: ENV['GEM_HOME'] = '/home/username/.gems' ENV['GEM_PATH'] = '$GEM_HOME:/usr/lib/ruby/gems/1.8' Still no luck. Same no such file to load bundler error appears. Has anybody got this working? Rails 3, Debian, shared host (dreamhost)? I could just go ahead and register on Slicehost/Fivebean but before I do, I'd like to know why that error is showing up. Thanks.

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >