Search Results

Search found 47324 results on 1893 pages for 'end users'.

Page 135/1893 | < Previous Page | 131 132 133 134 135 136 137 138 139 140 141 142  | Next Page >

  • error while using cancan in ruby: "uninitialized constant CanCan::Rule::Mongoid"

    - by Ran
    here is my controller: class AdminController < ApplicationController before_filter :require_user authorize_resource :class => false def index end def users_list end end here is my Ability class: class Ability include CanCan::Ability def initialize(user) if user.admin? can :manage, :all else can :read, :all end end end when trying to access "/admin/users_list" (with an admin user or without) i get the following error: uninitialized constant CanCan::Rule::Mongoid any thoughts?

    Read the article

  • Is it possible to filter users from a launchd plist?

    - by compriots
    I have some launchd plists that are now placed at the administrator per-user level, particularly inside: - /Library/LaunchAgents OR - /Library/LaunchDaemons I'd like to avoid that some of those services could start only for one user (possibly avoiding to move all the plists to ~/Library/LaunchAgents), which is the simplest way? Thanks in advance.

    Read the article

  • Using a ControlParameter in FilterParameters when the property is null

    - by end-user
    I have a DataList and FormView; they have separate datasources, though they pull the same info. The FormView's datasource has a FilterExpression to pull whatever's been selected on the DataList. On first load, the SelectedValue of the DataList is null (naturally). I expect the FilterExpression to result in zero rows, but it doesn't. If I set the DefaultValue to 0, it does, but then the parameter never updates when I select something from the DataList. Am I doing it wrong?

    Read the article

  • How to share the credentials between Webform and Winform?

    - by Daniel
    Hi! Question: I want to make a login form at the Clickonce deployment webpage, and only allow the authenticated users to download the application. and I want the downloaded application to use the same credentials entered at the webpage, without prompting the users to enter the credentials again. Details: I have an application(Windows Client) which needs customized settings for different users. the application is deployed through ClickOnce. Currently, the users are given the ClickOnce webpage URL, then download the application from there. after download and running the application, the application prompts users with a login form. If their credentials are authenticated, the application loads the customized settings from the server's database according to the credentials given. The problem is, any unauthenticated users can download the application if they just know the ClickOnce deployement webpage's URL. Unauthenticated users won't be able to run the application anyways, because the application asks for credentials when started, but I want to prevent the unauthenticated users from downloading the application at all. Am I asking the wrong question maybe? Your help is much appreciated!

    Read the article

  • How to create custom omniauth provider (how to return data)

    - by user2803917
    I searched all around the net, how to create a custom provider for omniauth.. and i succedded partly.. I created a gem, and it worked perfectly, except the part, that i cant understand how to return the gathered data to sessions controller, like other providers do.. here is the code in auth gem: require 'multi_json' require 'digest/md5' require 'rest-client' module OmniAuth module Strategies class Providername < OmniAuth::Strategies::OAuth attr_accessor :app_id, :api_key, :auth def initialize(app, app_id = nil, api_key = nil, options = {}) super(app, :providername) @app_id = app_id @api_key = api_key end protected def request_phase redirect "http://valid_url" end def callback_phase if request.params['code'] && request.params['status'] == 'ok' response = RestClient.get("http://valid_url2/?code=#{request.params['auth_code']}") auth = MultiJson.decode(response.to_s) unless auth['error'] @auth_data = auth if @auth_data @return_data = OmniAuth::Utils.deep_merge(super, { 'uid' => @auth_data['uid'], 'nickname' => @auth_data['nick'], 'user_info' => { 'first_name' => @auth_data['name'], 'last_name' => @auth_data['surname'], 'location' => @auth_data['place'], }, 'credentials' => { 'apikey' => @auth_data['apikey'] }, 'extra' => {'user_hash' => @auth_data} }) end end else fail!(:invalid_request) end rescue Exception => e fail!(:invalid_response, e) end end end end and here i call it in my initializers: Rails.application.config.middleware.use OmniAuth::Builder do provider "providername", Settings.providers.providername.app_id, Settings.providers.providername.app_secret end in this code, everything works fine so far, the provider gets called, i get the info from provider, i create a hash (@auth_data) with info, but how do i return it

    Read the article

  • ruby on rails one-to-many relationship

    - by fenec
    I would like to model a betting system relationship using the power of rails. so lets start with doing something very simple modelling the relationship from a user to a bet.i would like to have a model bet with 2 primary keys. here are my migrations enter code here class CreateBets < ActiveRecord::Migration def self.up create_table :bets do |t| t.integer :user_1_id t.integer :user_2_id t.integer :amount t.timestamps end end def self.down drop_table :bets end end class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.timestamps end end def self.down drop_table :users end end the models enter code here class Bet < ActiveRecord::Base belongs_to :user_1,:class_name=:User belongs_to :user_2,:class_name=:User end class User < ActiveRecord::Base has_many :bets, :foreign_key =:user_1) has_many :bets, :foreign_key =:user_2) end when i test here in the console my relationships I got an error enter code here u1=User.create :name="aa" = # u2=User.create :name="bb" = # b=Bet.create(:user_1=u1,:user_2=u2) *****error***** QUESTIONS: 1 How do I define the relationships between these tables correctly? 2 are there any conventions to name the attributes (ex:user_1_id...) thank you for your help

    Read the article

  • Make JFace Window blink in taskbar or get users attention?

    - by Sophomore
    Hi folks I wonder someone has any idea how to solve this: In my Java Eclipse plugin there are some processes which take some time. Therefore the user might minimize the window and let the process run in the background. Now, when the process is finished, I can force the window to come to the top again, but that is a no-no in usability. I'd rather want the process to blink in the taskbar instead. Is there any way to achieve this? I had a look at the org.eclipse.jface.window but could'nt find anything like that, same goes for the SWT documentation... Another thing which came to my mind - as people are using this app on mac os x and linux as well, is there a platform independant solution, which will inform the user that the process has finished but without bringing the window to the top? Any ideas are highly welcome! Edit: I found out that on windows the user can adjust whether he would like to enable a force to foreground or not. If that option is disabled, the task will just blink in the taskbar... Here's a good read on that... If anyone maybe knows about some platform independant way of achieving this kind of behaviour, please share your knowledge with me!

    Read the article

  • Error when installing wubi on windows 7

    - by P'sao
    Im installing ubuntu on windows 7(wubi 11.10): when its nearly done it gives me this error in the log file: Usage: /cygdrive/c/Users/Psao/AppData/Local/Temp/pyl10D2.tmp/bin/resize2fs.exe -f C:/ubuntu/disks/root.disk 17744M [-d debug_flags] [-f] [-F] [-p] device [new_size] Traceback (most recent call last): File "\lib\wubi\backends\common\tasklist.py", line 197, in __call__ File "\lib\wubi\backends\win32\backend.py", line 461, in expand_diskimage File "\lib\wubi\backends\common\utils.py", line 66, in run_command Exception: Error executing command >>command=C:\Users\P'sao\AppData\Local\Temp\pyl10D2.tmp\bin\resize2fs.exe -f C:\ubuntu\disks\root.disk 17744M >>retval=1 >>stderr= >>stdout=resize2fs 1.40.6 (09-Feb-2008) Usage: /cygdrive/c/Users/Psao/AppData/Local/Temp/pyl10D2.tmp/bin/resize2fs.exe -f C:/ubuntu/disks/root.disk 17744M [-d debug_flags] [-f] [-F] [-p] device [new_size] 10-25 20:31 DEBUG TaskList: # Cancelling tasklist 10-25 20:31 DEBUG TaskList: # Finished tasklist 10-25 20:31 ERROR root: Error executing command >>command=C:\Users\P'sao\AppData\Local\Temp\pyl10D2.tmp\bin\resize2fs.exe -f C:\ubuntu\disks\root.disk 17744M >>retval=1 >>stderr= >>stdout=resize2fs 1.40.6 (09-Feb-2008) Usage: /cygdrive/c/Users/Psao/AppData/Local/Temp/pyl10D2.tmp/bin/resize2fs.exe -f C:/ubuntu/disks/root.disk 17744M [-d debug_flags] [-f] [-F] [-p] device [new_size] Traceback (most recent call last): File "\lib\wubi\application.py", line 58, in run File "\lib\wubi\application.py", line 132, in select_task File "\lib\wubi\application.py", line 158, in run_installer File "\lib\wubi\backends\common\tasklist.py", line 197, in __call__ File "\lib\wubi\backends\win32\backend.py", line 461, in expand_diskimage File "\lib\wubi\backends\common\utils.py", line 66, in run_command Exception: Error executing command >>command=C:\Users\P'sao\AppData\Local\Temp\pyl10D2.tmp\bin\resize2fs.exe -f C:\ubuntu\disks\root.disk 17744M >>retval=1 >>stderr= >>stdout=resize2fs 1.40.6 (09-Feb-2008) Usage: /cygdrive/c/Users/Psao/AppData/Local/Temp/pyl10D2.tmp/bin/resize2fs.exe -f C:/ubuntu/disks/root.disk 17744M [-d debug_flags] [-f] [-F] [-p] device [new_size] can some one help me?

    Read the article

  • ruby nested classes and modules

    - by ash34
    Hi, I am familiar with the concept of nesting classes and modules within another module and grouping them in a namespace. What is the idea / purpose behind Nesting classes within another class class A class B def method_B ... end end end 2.Nesting modules within another class class A module c def method_c ... end end end thanks, ash

    Read the article

  • after_create :create a new line in DB

    - by Karl Entwistle
    Hey guys I was wondering if anyone could help me with an issue im having, basically id like to have Account.create after a PayPal notification is received, There is a simple cart model which corresponds to line_items within the cart so add_account_to_market would look like this in pseudo code def add_account_to_market if status == "Completed" find the line items(via cart_id) that correspond to the cart.id that just been paid create an account with user_id set to the current carts user id end end Ive never tried to do something like this in Rails and its not working, Ive been pulling my hair out all night trying to fix this, hopefully someone can help or point me in the right direction. Thanks :) class PaymentNotification < ActiveRecord::Base belongs_to :cart serialize :params after_create :mark_cart_as_purchased after_create :add_account_to_market private def mark_cart_as_purchased if status == "Completed" cart.update_attribute(:purchased_at, Time.now) cart.update_attribute(:paid, true) end end def add_account_to_market if status == "Completed" l = LineItem.find(:all, :conditions => "cart_id = '#{cart.id}'") for l.quantity Account.new(:user_id => cart.user_id) end end end end PS mark_cart_as_purchased method is working fine, its just the add_account_to_market im having issues with.

    Read the article

  • How to reference using Entity Framework and Asp.Net Mvc 2

    - by Picflight
    Tables CREATE TABLE [dbo].[Users]( [UserId] [int] IDENTITY(1,1) NOT NULL, [UserName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [Email] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [BirthDate] [smalldatetime] NULL, [CountryId] [int] NULL, CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ([UserId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] CREATE TABLE [dbo].[TeamMember]( [UserId] [int] NOT NULL, [TeamMemberUserId] [int] NOT NULL, [CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_TeamMember_CreateDate] DEFAULT (getdate()), CONSTRAINT [PK_TeamMember] PRIMARY KEY CLUSTERED ([UserId] ASC, [TeamMemberUserId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] dbo.TeamMember has both UserId and TeamMemberUserId as the index key. My goal is to show a list of Users on my View. In the list I want to flag, or highlight the Users that are Team Members of the LoggedIn user. My ViewModel public class UserViewModel { public int UserId { get; private set; } public string UserName { get; private set; } public bool HighLight { get; private set; } public UserViewModel(Users users, bool highlight) { this.UserId = users.UserId; this.UserName = users.UserName; this.HighLight = highlight; } } View <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcPaging.IPagedList<MyProject.Mvc.Models.UserViewModel>>" %> <% foreach (var item in Model) { %> <%= item.UserId %> <%= item.UserName %> <%if (item.HighLight) { %> Team Member <% } else { %> Not Team Member <% } %> How do I toggle the TeamMember or Not If I add dbo.TeamMember to the EDM, there are no relationships on this table, how will I wire it to Users object? So I am comparing the LoggedIn UserId with this list(SELECT TeamMemberUserId FROM TeamMember WHERE UserId = @LoggedInUserId)

    Read the article

  • Need help with a SQL CTE Query

    - by Chuck
    I have a table that I need to get some specific data from for a view. Here's the base table structure with some sample data: | UserID | ReportsToUserID | Org ID | ------------------------------------- | 1 | NULL | 1 | ------------------------------------- | 2 | 1 | 1 | ------------------------------------- | 3 | 2 | 1 | ------------------------------------- | 4 | 3 | 1 | ------------------------------------- The users will be entering reports and users can see the reports of users who report to them and any users who report to those users. Users who report to no one can see everything in their organization Given my sample data above, user 1 can see the reports of 2, 3, & 4; user 2 can see the reports of 3 & 4; and user 3 can see the reports of 4. For the view, I'd like to have the data returned as follows: | UserID | CanSeeUserID | OrgID | -------------------------------------------- | 1 | 2 | 1 | -------------------------------------------- | 1 | 3 | 1 | -------------------------------------------- | 1 | 4 | 1 | -------------------------------------------- | 2 | 3 | 1 | -------------------------------------------- etc... Below is my current code, any help is greatly appreciated. WITH CTEUsers (UserID, CanSeeUserID, OrgID) AS ( SELECT e.ID, e.ReportsToUserID, e.OrgID FROM Users e WITH(NOLOCK) WHERE COALESCE(ReportsToUserID,0) = 0 --ReportsToUserID can be NULL or 0 UNION ALL SELECT e.ReportsToUserID, e.ID,e.OrgID FROM Users e WITH(NOLOCK) JOIN CTEUsers c ON e.ID = c.UserID ) SELECT * FROM CTEUsers

    Read the article

  • Will this class cause memory leaks, and does it need a dispose method? (asp.net vb)

    - by Phil
    Here is the class to export a gridview to an excel sheet: Imports System Imports System.Data Imports System.Configuration Imports System.IO Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Namespace ExcelExport Public NotInheritable Class GVExportUtil Private Sub New() End Sub Public Shared Sub Export(ByVal fileName As String, ByVal gv As GridView) HttpContext.Current.Response.Clear() HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName)) HttpContext.Current.Response.ContentType = "application/ms-excel" Dim sw As StringWriter = New StringWriter Dim htw As HtmlTextWriter = New HtmlTextWriter(sw) Dim table As Table = New Table table.GridLines = GridLines.Vertical If (Not (gv.HeaderRow) Is Nothing) Then GVExportUtil.PrepareControlForExport(gv.HeaderRow) table.Rows.Add(gv.HeaderRow) End If For Each row As GridViewRow In gv.Rows GVExportUtil.PrepareControlForExport(row) table.Rows.Add(row) Next If (Not (gv.FooterRow) Is Nothing) Then GVExportUtil.PrepareControlForExport(gv.FooterRow) table.Rows.Add(gv.FooterRow) End If table.RenderControl(htw) HttpContext.Current.Response.Write(sw.ToString) HttpContext.Current.Response.End() End Sub Private Shared Sub PrepareControlForExport(ByVal control As Control) Dim i As Integer = 0 Do While (i < control.Controls.Count) Dim current As Control = control.Controls(i) If (TypeOf current Is LinkButton) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, LinkButton).Text)) ElseIf (TypeOf current Is ImageButton) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, ImageButton).AlternateText)) ElseIf (TypeOf current Is HyperLink) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, HyperLink).Text)) ElseIf (TypeOf current Is DropDownList) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, DropDownList).SelectedItem.Text)) ElseIf (TypeOf current Is CheckBox) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, CheckBox).Checked)) End If If current.HasControls Then GVExportUtil.PrepareControlForExport(current) End If i = (i + 1) Loop End Sub End Class End Namespace Will this class cause memory leaks? And does anything here need to be disposed of? The code is working but I am getting frequent crashes of the app pool when it is in use. Thanks.

    Read the article

  • Load balancing a php program to support increasing users?

    - by Dave
    I have a php program that has been written keeping in mind a single server, so there are inherent limitation to how much it can handle. For example, the developer says that his current webhosting service provides him with "50 mysql connections" which he interprets as that only 50 people can be simultaneously logged onto it. What do we need to do if we want to scale it up so it can handle a load of 500 or more? How can we adapt this program to a "load balancer" with minimal changes? The application is writen in php and uses mysql.

    Read the article

  • Problems with rails and saving to the database.

    - by Grantismo
    I've been having some difficulty in understanding the source of a problem. Below is a listing of the model classes. Essentially the goal is to have the ability to add sentences to the end of the story, or to add stories to an existing sentence_block. Right now, I'm only attempting to allow users to add sentences, and automatically create a new sentence_block for the new sentence. class Story < ActiveRecord::Base has_many :sentence_blocks, :dependent => :destroy has_many :sentences, :through => :sentence_blocks accepts_nested_attributes_for :sentence_blocks end class SentenceBlock < ActiveRecord::Base belongs_to :story has_many :sentences, :dependent => :destroy end class Sentence < ActiveRecord::Base belongs_to :sentence_block def story @sentence_block = SentenceBlock.find(self.sentence_block_id) Story.find(@sentence_block.story_id) end end The problem is occurring when using the show method of the Story. The Story method is as follows, and the associated show method for a sentence is also included. Sentence.show def show @sentence = Sentence.find(params[:id]) respond_to do |format| format.html {redirect_to(@sentence.story)} format.xml { render :xml => @sentence } end end Story.show def show @story = Story.find(params[:id]) @sentence_block = @story.sentence_blocks.build @new_sentence = @sentence_block.sentences.build(params[:sentence]) respond_to do |format| if @new_sentence.content != nil and @new_sentence.sentence_block_id != nil and @sentence_block.save and @new_sentence.save flash[:notice] = 'Sentence was successfully added.' format.html # new.html.erb format.xml { render :xml => @story } else @sentence_block.destroy format.html format.xml { render :xml => @story } end end end I'm getting a "couldn't find Sentence_block without and id" error. So I'm assuming that for some reason the sentence_block isn't getting saved to the database. Can anyone help me with my understanding of the behavior and why I'm getting the error? I'm trying to ensure that every time the view depicts show for a story, an unnecessary sentence_block and sentence isn't created, unless someone submits the form, I'm not really sure how to accomplish this. Any help would be appreciated.

    Read the article

  • How do i structure my SQL Database (tables, Schemas, users, stored procedures etc.) to prepare it fo

    - by AlexRednic
    I think the title is self explanatory. What I'm looking for is material so I can further my knowledge. I've never developed a full application before so building one from scratch is a bit overwhelming for me. And the first bump in the road is the database. Websites, articles, books, elaborate answers, anything will do as long as they keep me on the right track. Thanks

    Read the article

  • Should my validator have access to my entire model?

    - by wb
    As the title states I'm wondering if it's a good idea for my validation class to have access to all properties from my model. Ideally, I would like to do that because some fields require 10+ other fields to verify whether it is valid or not. I could but would rather not have functions with 10+ parameters. Or would that make the model and validator too coupled with one another? Here is a little example of what I mean. This code however does not work because it give an infinite loop! Class User Private m_UserID Private m_Validator Public Sub Class_Initialize() End Sub Public Property Let Validator(value) Set m_Validator = value m_Validator.Initialize(Me) End Property Public Property Get Validator() Validator = m_Validator End Property Public Property Let UserID(value) m_UserID = value End property Public Property Get UserID() UserID = m_Validator.IsUserIDValid() End property End Class Class Validator Private m_User Public Sub Class_Initialize() End Sub Public Sub Initialize(value) Set m_User = value End Sub Public Function IsUserIDValid() IsUserIDValid = m_User.UserID > 13 End Function End Class Dim mike : Set mike = New User mike.UserID = 123456 mike.Validator = New Validator Response.Write mike.UserID If I'm right and it is a good idea, how can I go a head and fix the infinite loop with the get property UserID? Thank you.

    Read the article

  • Letting users trial your web app before sign-up: sessions or temp db?

    - by Mat
    I've seen a few instances now where web applications are letting try them out without you having to sign-up (though to save you need to of course). example: trial at http://minutedock.com/ I'm wondering about doing this for my own web app and the fundamental question is whether to store their info into sessions or into a temp user table? The temp user table would allow logging and potentially be less of a hit on the server correct? Is there a best practice here?

    Read the article

  • How to (kindly) ask your users to upgrade from IE6?

    - by nickf
    It's no secret at all that IE6 has been a major roadblock to the advancement of the web over the last few years. I couldn't count the number of hours I've spent bashing my head against a wall trying to fix or debug IE6 issues. The way I see it, there are two types of IE6 user. a) the poor corporate schmoe whose IT department doesn't want to upgrade in case something breaks, and b) the mums and dads of the world who think the internet is the blue E on their desktop (and I don't mean that in a nasty way). There's probably a couple of people who know about all the other browsers, but still choose to run IE6. They get what they deserve, IMO. Anyway, getting to the point, I'd say that 90% of my IE6-using visitors are in the the mums and dads category - they're not stupid, they just don't know WHY they should upgrade to IE7 or Firefox or whatever. How do I educate these people without pissing them off? Is there a nice and friendly website I can direct these people to, which explains the reasons for upgrading in plain language? Any mention of "security" or "web standards" I think would just come across as scary. I've just seen http://www.whatbrowser.org which seems to fit the bill nicely. It explains in very basic terms: what a web browser is why you'd want to upgrade it how old your current browser is (subtle hint to those with a 9 year old browser) ..aaaand it's in 22 languages. It's from Google but displays no bias (it links to Firefox, Chrome, Opera, Safari, Internet Explorer displayed in a random order).

    Read the article

  • JQuery - Pass variables to PHP script via AJAX call and then display file

    - by hfidgen
    Hiya, I'm trying to generate Outlook event files for my events, doing so on the fly as and when someone requests it by pressing a link on the page. Here's what i've got so far, but I can't find out how to get the browser to download the content which is returned. I know how I could do this if I sent everything via _GET, but I'd prefer to do it via _POST, hence I'm going down this route.. Any thoughts? Thanks! HTML / Javascript <script> $(function() { $(".button").click(function() { // validate and process form // first hide any error messages var start = $("input#start").val(); var end = $("input#end").val(); var dataString = 'start='+ start + '&end=' + end; $.ajax({ type: "POST", url: "/calendar.php", data: dataString, success: function(data) { //Need to return the file contents somehow! } }); return false; }); }); </script> <form name="calendar" method="post" action=""> <input type="hidden" name="start" id="start" value="<?php echo $start; ?>" /> <input type="hidden" name="end" id="end" value="<?php echo $end; ?>" /> <input type="submit" name="submit" class="button" id="submit_btn" value="Outlook" /> </fieldset> </form> PHP File <?php if (isset($_POST['start'])) { $start = $_POST['start']; $end = $_POST['end']; $c = header("Content-Type: text/Calendar"); $c .= header("Content-Disposition: inline; filename=calendar.ics"); $c .= "BEGIN:VCALENDAR\n"; $c .= "VERSION:2.0\n"; $c .= "PRODID:-//xxxyyyy//NONSGML //EN\n"; $c .= "METHOD:REQUEST\n"; // requied by Outlook $c .= "BEGIN:VEVENT\n"; $c .= "UID:". $start . $end ."-" . "-xxxxyyyy.com\n"; // required by Outlook $c .= "DTSTAMP:".date('Ymd').'T'.date('His')."\n"; // required by Outlook $c .= "DTSTART:20080413T000000\n"; $c .= "SUMMARY:" . "\n"; $c .= "DESCRIPTION:" . "\n"; $c .= "END:VEVENT\n"; $c .= "END:VCALENDAR\n"; echo $c; } else { echo "Sorry you can't access this page directly"; } ?>

    Read the article

  • Ruby and public_method_defined? : strange behaviour

    - by aXon
    Hi there Whilst reading through the book "The well grounded Rubyist", I came across some strange behaviour. The idea behind the code is using one's own method_missing method. The only thing I am not able to grasp is, why this code gets executed, as I do not have any Person.all_with_* class methods defined, which in turn means that the self.public_method_defined?(attr) returns true (attr is friends and then hobbies). #!/usr/bin/env ruby1.9 class Person PEOPLE = [] attr_reader :name, :hobbies, :friends def initialize(mame) @name = name @hobbies = [] @friends = [] PEOPLE << self end def has_hobby(hobby) @hobbies << hobby end def has_friend(friend) @friends << friend end def self.method_missing(m,*args) method = m.to_s if method.start_with?("all_with_") attr = method[9..-1] if self.public_method_defined?(attr) PEOPLE.find_all do |person| person.send(attr).include?(args[0]) end else raise ArgumentError, "Can't find #{attr}" end else super end end end j = Person.new("John") p = Person.new("Paul") g = Person.new("George") r = Person.new("Ringo") j.has_friend(p) j.has_friend(g) g.has_friend(p) r.has_hobby("rings") Person.all_with_friends(p).each do |person| puts "#{person.name} is friends with #{p.name}" end Person.all_with_hobbies("rings").each do |person| puts "#{person.name} is into rings" end The output is is friends with is friends with is into rings which is really understandable, as there is nothing to be executed.

    Read the article

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