Search Results

Search found 9437 results on 378 pages for 'rails newbie'.

Page 137/378 | < Previous Page | 133 134 135 136 137 138 139 140 141 142 143 144  | Next Page >

  • How do you share pre-calculated data between calls to a Rails web service?

    - by Nigel Thorne
    I have a Rails app that allows users to build up a network structure and then ask questions about how to navigate around it. When adding nodes and connections these are just saved to the database. At the point you make a query of the network I calculate the shortest path from any node to any other node. Constructing this in memory takes a while (something I need to fix), but once it is there, you can instantly get the answer to any of these path questions. The question is... How do I share this network between calls to the website, so each request doesn't regenerate the paths network each time? Note: I am hosting this on apache server using passenger (mod ruby) Thoughts?

    Read the article

  • How do I write a spec for a Rails route that does redirecting?

    - by winstonyw
    I am using Omniauth in my Rails project, and I'll like to hide "/auth/facebook" behind a "/login" route. In fact, I wrote a route: match "/login", :to => redirect("/auth/facebook"), :as => :login and this actually works, i.e. a link to login_path will redirect to /auth/facebook. However, how can I write a (rspec) spec to test this route (specifically, the "redirect" option)? Do note that /login is not an actual action nor method defined in application. Thanks in advance!

    Read the article

  • Installing sqlite on windows xp for ruby on rails?

    - by bennybdbc
    I've been trying to follow this guide to installing ruby and rails on my new machine. I'm having problems, however, when it comes to the sqlite gem. I installed the gem, which seemed to work perfectly. Then, however, it tells me to download a zip file from http://www.sqlite.org/sqlitedll-3_7_3.zip. When I do, the file is downloaded, but it doesn't seem to be a zip file. It has the icon of a microsoft word file, and clicking on it opens up Word but the file isn't opened, it just shows error messages. There is no option to extract the file, which is what the guide says to do. Is this a problem with sqlite or my machine? Any help would be appreciated.

    Read the article

  • Rails Application expecting me to restart my webrick server for any change in my controller.

    - by Vamsi
    I am working on an existing Rails 2.3.x application, So I was working on it and it was a messy code with great difficulty I was able to run the application. But now for every small change in one of my controller it is expecting me to restart my serer otherwise the changes are not reflecting back, Let's take an example scenario here, Let's just say in one of the before_filter method I just added a puts statement on top of the method and it was not printing in the log, after I restart the server it is printing, Can some one please let me know if I am missing something here.

    Read the article

  • How to Tweet from multiple acounts with twitter Gem in Rails?

    - by Jmlevick
    I have an application wich has Oauth access using Twitter as provider. I also have the ability to ask the logged user permisson to Read and Write in his/her account and once a user authorized the app, I can send tweets as the user with something like: u = User.find(id) u.twitter.update("Some-Status-Here") in the rails console... What I want to do is to Tweet as all the users in one command, but if I try something like: u = User.all u.twitter.update("Some-Status-Here") I get this error: undefined method `twitter' for #<Array:0x00000002e2f188> How can I tweet as all the users in one command? What am I doing wrong? I feel it is a very basic thing I'm missing... Can someone help me? Thank You.

    Read the article

  • Rails: Is there a way to check for incomplete JPG file upload?

    - by user206481
    I have a Rails app that processes and serves up jpg files that were uploaded via FTP. On several occasions the FTP process was disconnected and left many incomplete .jpg files. I was surprised to see that the incomplete jpgs behave as normal jpg files in my app even tho they have incomplete image data. I have since implemented a more robust FTP process where the uploaded file is initially *.tmp and gets renamed to .jpg after an FTP success code is received. My problem is, I still have all of these incomplete jpg files on the server and can't figure out how to programmatically weed them out. I can actually display them in a view without generating any errors, but there is only a partial image there. I tried RMagick but they all successfully load (using Image.read) and report the valid x & y resolutions. I have so far not been able to determine a way to programmatically differentiate between an incomplete and complete jpg uploaded image. Any ideas?

    Read the article

  • How do I run multiple objects through an IF statement in rails?

    - by codyvbrown
    I am creating an application that highlights user messages from a stream based on whether or not the user has been 'vouched'. It works fine if it's setup for a single author. For example controller: @vouch = Vouch.last.vouched_user_nickname view: <% if tweet.from_user == @vouch %> <div class="flit_message_containerh">.... But I'm having trouble doing it for multiple user nicknames. @vouch = Vouch.find(:all, :select => "vouched_user_nickname", :group => 'vouched_user_nickname' ) Any ideas would be greatly appreciated. I'm a rails noob.

    Read the article

  • A new Rails idea in views and no more controller. maybe better maybe worse, i need help if this is t

    - by Totty
    Hy, I was thinking that all my website will have use of cells, using the known plugin cell for rails, so this is my idea: A table that contains 3 fields: id, view_name and layout. the layout will be a serialized hash. When a request is made, the layout field is requested and then in the view, default layout, will be unserialized the layout var, that looks like this: @layout[:sidecol][:gallery] = {... some params for it...}; @layout[:maincol][:comments] = {..params...}; In the <% #ruby code to render the cells in the @layout[:sidecol] % will be some ruby code that will loop over the @layout[:sidecol] and render all cells in it. the same occurs in the maincol div. What do you think? Positive in my opinion: More modular controller is used only for post easy change of structure easier to implement some kind of traking to see diferences on what layout is better or not. Negative: not found yet

    Read the article

  • Rails: How can I log all requests which take more than 4s to execute?

    - by Fedyashev Nikita
    I have a web app hosted in a cloud environment which can be expanded to multiple web-nodes to serve higher load. What I need to do is to catch this situation when we get more and more HTTP requests (assets are stored remotely). How can I do that? The problem I see from this point of view is that if we have more requests than mongrel cluster can handle then the queue will grow. And in our Rails app we can only count only after mongrel will receive the request from balancer.. Any recommendations?

    Read the article

  • Ruby on Rails ActiveScaffold: Showing {{model}} instead of model name?

    - by AnExtremelySmellyPerson
    Hi there, I'm using ActiveScaffold with Ruby on Rails and I'm loving it, however there is one weird thing. Whenever I hit "Edit" or "Create New" in my webapp's ActiveScaffold, it says "Create {{model}}" or "Update {{model}}" in the webapp rather than using the model's name. Why is this? I have an ads_controller.rb that includes this: active_scaffold :ad do |config| config.label = "Ads" config.columns = [:name, :description, :imageUrl, :linkUrl, :apps, :created_at, :updated_at] config.update.columns = [:name, :description, :imageUrl, :linkUrl, :apps] config.create.columns = config.update.columns list.sorting = {:created_at => 'DESC'} columns[:imageUrl].label = "Image URL" columns[:linkUrl].label = "Link URL" end And my routes.rb includes this: map.namespace :admin do |admin| admin.root :controller => 'admin_home', :action => 'index' admin.resources :ads, :active_scaffold => true end Any thoughts on why I'm seeing "Create {{model}}" instead of "Create ad" ?

    Read the article

  • What database to use with Ruby on Rails, based on actual Hosting services ?

    - by IHawk
    Hello ! I've been looking for hosting services and I still don't know what kind of database is the most commom. It seems to be MySql and PostgreSql. So, I'm not sure about how much traffic and data my website will have (it's just a project), but I would like to be prepared. I've worked in some projects with Oracle (PL/SQL) and I know something from MySql. Based in this facts, What database to use with Ruby on Rails, based on actual Hosting services ? Thank you !

    Read the article

  • which technology is best for a Facebook application Ruby on Rails or C# and ASP?

    - by Johnny
    hi, My friend and I want to write a Facebook application. We've narrowed down the list of possible technologies to Ruby on Rails and C# with ASP. Here are the pros and cons we've thought of. Cons: ASP - proprietary tools like Visual Studio etc. cost (lots of) money. We both don't know ASP (although we're not bad at C#). RoR - It's scripting so might be harder to maintain. My friend doesn't know RoR at all (but he's a fairly proficient programmer so will probably be able to pick it up quickly). Pros: ASP - Facebook has an official SDK for .NET. RoR - I know RoR. It's open source, free and has fast development time. What says the community? Is there something we haven't thought of?

    Read the article

  • How do I setup a shared session between two users on my Ruby on Rails powered site?

    - by ben
    Hey guys, The website that I'm building includes a section where two users can interact. I think I know how to do most of it, except the actual session sharing part. I'm using Ruby on Rails & Javascript (jquery), and I've got user login and session management all working okay. Would the best way to create a shared session be to have a SharedSession model, with accompanying database table, with participant1ID, participant2ID etc? Is there a better way? Thanks so much for reading!

    Read the article

  • Rails - How do you dynamically call the request methods "get put destroy etc" at runtime in tests

    - by adam
    I'm always writing tests to check my controller restricts people from certain actions depending on their status i.e. logged in, admin? etc Regardless of whether its a get to :index or a puts to :create the code is always the same. I'm trying to refactor this so that i have one method such as should_redirect_unauthenticated_to_login_action(request, action) and call it like so should_redirect_unauthenticated_to_login_action(:get, :index) = get :index But not sure how to dynamically call the various response methods rails provides for functional tests which seem to live in the module ActionController I mucked around with module = Kernel.const_get("ActionController") module::TestProcess.get NoMethodError: undefined method `get' for ActionController::TestProcess:Module can anyone help (im very new to dynamic calling in ruby)

    Read the article

  • How to deal with time zones in a Rails app with events...

    - by Tony
    I have a Rails app for bands. Bands can import their shows which all occur in different time zones. It seems like a ton of work to store these events in UTC. I would have to figure out the time zone for any show created and then convert back to the show's local time zone when displaying to the user. Is there a simple plugin to get a UTC offset based on geolocation? That would probably help, but does anyone see any major reasons why I should store in UTC here? I understand storing timestamps in UTC is probably a good idea...but band event times?

    Read the article

  • How do I produce an external URL as part of a replace_html call in Ruby on Rails?

    - by vlasits
    Basically, I am attempting to render an external website (the url of which is stored in the database) into a page in my Ruby on Rails app. I have a field in my model 'search' called 'search' that contains web addresses with the form 'www.example.com' or 'example.com'. I am trying to use a link_to_function call with replace_html to replace the 'maincontent' div with an iframe tag using the value of 'search' in the current instance as the src for the tag. My current attempt is the very ugly code below. I'd be grateful for either of the following types of responses: How can I rewrite the concatenation string to work correctly? How can I get the same effect (replacing the current content of the "mainContent" div with an iframe tag using a different method? (I had to modify the code before to remove the < from the iframe) link_to_function h(search.title) do |page| page.replace_html 'mainContent', 'iframe id="embedded" src="http://" + #{search.search} />' end

    Read the article

  • Rails 3 namespacing requires model to be defined twice?

    - by RSG
    I'm pulling my hair out trying to understand namespacing in Rails 3. I've tried following a few different tutorials, and the only way I can get my models to work is if I define my model in both the base directory and my namespace directory. If I only define the model in the namespace directory it expects it to define both Model and Namespace::Model, as below: LoadError (Expected .../app/models/plugins/chat.rb to define Chat): or LoadError (Expected .../app/models/plugins/chat.rb to define Plugins::Chat): I'm sure I'm missing something obvious, but I could really use a pointer in the right direction. Here are the relevant excerpts. /models/plugins/chat.rb class Plugins::Chat include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming ... end /controllers/plugins/chats_controller.rb class Plugins::ChatsController < Plugins::ApplicationController load_and_authorize_resource ... end /config/routes.rb namespace :plugins do resources :chats end /config/application.rb config.autoload_paths += Dir["#{config.root}/app/models/**/"]

    Read the article

  • How can I figure out where all these extra sqlite3 selects are being generated in my rails app?

    - by radixhound
    I'm trying to figure out where a whole pile of extra queries are being generated by my rails app. I need some ideas on how to tackle it. Or, if someone can give me some hints, I'd be grateful. I get these: SQL (1.0ms) SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence' SQL (0.8ms) SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence' SQL (0.8ms) SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence' repeated over and over on every request to the DB (as much as 70 times for a single request) I tried installing a plugin that traced the source of the queries, but it really didn't help at all. I'm using the hobofields gem, dunno if that is what's doing it but I'm somewhat wedded to it at the moment Any tips on hunting down the source of these extra queries?

    Read the article

  • Rails activerecord includes. How to access the included columns?

    - by Lee Quarella
    I my User has_many :event_patrons and EventPatron belongs_to :user. I would like to slap together the user with one specific event patron with something like this sql statement: SELECT * FROM `users` INNER JOIN `event_patrons` ON `event_patrons`.`user_id` = `users`.`id` WHERE `event_patrons`.`event_id` = 1 So in rails I tried this: User.all(:joins => :event_patrons, :condidions => {:event_patrons => {:event_id => 1}}) But that gives me SELECT users.* instead of SELECT *: SELECT `users`* FROM `users` INNER JOIN `event_patrons` ON `event_patrons`.`user_id` = `users`.`id` WHERE `event_patrons`.`event_id` = 1 I then tried to switch the :joins with :include and got a whole jumbled mess that still returned me only the columns in User and none from EventPatron. What am I missing?

    Read the article

  • Rails show view of one model with form for adding one child - nested attributes vs seperate controll

    - by SWR
    I have a basic two tiered model structure: Articles - Comments with one Article having many comments. What is the best way to add a "Add a comment" form to the bottom of the Articles show page? nested_attributes is overkill as I don't want to be able to edit all of the comments on the page, just to add one more. Is the best way even with Rails 2.3 still to make a separate controller and embed a form_for pointing to the other controller into the Articles show view? If so, how do I get validation errors to return to the article display page? I don't want to make a separate comment page/view... thanks

    Read the article

  • I built my rails app with sqlite and without specifying any db field sizes, Is my app now foobared for production?

    - by Tim Santeford
    I've been following a lot of good tutorials on building rails apps but I seem to be missing the whole specifying and validating db field sizes part. I love not needing to have to think about it when roughing out an app (I would have never done this with a PHP or ASP.net app). However, now that I'm ready to go to production, I think I might have done myself a disservice by not specifying field sizes as I went. My production db will be MySQL. What is the best practice here? Do I need to go through all of my migration files and specify sizes, update all the models with validation, and update all my form partial views with input max widths? or am I missing a critical step in my development process?

    Read the article

  • What is the best place to store globals in Rails app?

    - by Nick Gorbikoff
    Hello. I was wondering if there is the best practice on where to store global settings in a rails app. What I mean by that is i.e: I have a few globals defined that may change, but not likely and it seems inappropriate to store them in DB since they are used so much. For instance I have SYSTEM_EMAIL & SYSTEM_EMAIL_SIGNATURE & SYSTEM_STORAGE_ROOT. Right now I keep them in environment.rb, but I'm not sure if this is the right palce to store them. Thank you

    Read the article

  • Rails view error "invalid byte sequence in US-ASCII" error after upgrading Ruby to 1.9.2

    - by Jon
    Running Rails 2.3.9 and just upgraded to Ruby 1.9.2p0. I have been putting: # encoding: utf-8 in a bunch of my .rb files where ever "£" character is used, and this seems to be working. But i just got my first view error: invalid byte sequence in US-ASCI for this line of code: <%= number_to_currency(product.price, :unit => "£", :precision => 0) %> I don't think its a coincidence that the "£" character is involved again. Any ideas on how to solve this please? Thanks

    Read the article

  • How did this Ruby on Rails app get deployed?

    - by Ciera
    I have a Ruby on Rails app running on my server, and I can't figure out how it was deployed (someone else set it up). The app is located in /var/www/myapp. Before it was deployed, I had been able to go in there and make minor edits to the app. The person helping me out with RoR then "deployed" it. It was unclear what deploying actually did, since it points to the same database and is on the same server. However, I can no longer edit it (or at least, the files I am editing are not being pointed to by the server). Any way to figure out how this thing was deployed so I can take it down to edit it? Or should I basically just start over?

    Read the article

  • Writing To The Response in Rails? (Like "echo" in PHP)

    - by Yar
    I know that I can do this in Rails: <%="hello" %> but is there any way to do this <% echo "hello" %> and get it to show up in the response? I have tried response.write which almost worked, but did not... Edit: print or puts do not do it, because I do not want to write to the console. I want to write to the browser/HTTP client. Edit: Here is an example: <% unless @research_activities.size == 0 concat(render(:partial => 'list')) end %> Why would I want to include two closing tags just to do that? It reads nicely in code, doesn't it?

    Read the article

< Previous Page | 133 134 135 136 137 138 139 140 141 142 143 144  | Next Page >